var VACATION_DAY_OF_NEW_ASSIGN=0;var VACATION_NEW_ASSIGN=0;function vacationDayOfListOnLoad(){showNotification();setPageTitleWhoCall("4401-4402-4403","VACDAYOFLIST","Lista de dispensas");function cdoLoad(){fillSelectDependencyFull("selVacDayOfListDependency",-1,1);fillSelectSex("selVacDayOfListSex",-1);fillSelectCountry("selVacDayOfListCountry",-1);fillSelectDepartment("selVacDayOfListDepartment",-1);fillSelectEmployeeCategory("selVacDayOfListEmployeeCategory",-1);var date=new Date();setElementValue("txtVacDayOfListInitialDate",setLocalDate(new Date(date.getFullYear(),date.getMonth(),1),10));setElementValue("txtVacDayOfListEndDate",setLocalDate(new Date(),10));setTriggerButtonByText('txtVacDayOfListInitialDate','btVacDayOfListViewAll');setTriggerButtonByText('txtVacDayOfListEndDate','btVacDayOfListViewAll');if(!checkPermission("4002")){removeElement("btEmpLisNewEmployee");removeElement("divEmployeeRegister")}
if(!checkPermission("4111")){removeElement("btEmpWorSchRegWorkscheduleNew");removeElement("divWorkscheduleRegister")}
if(!checkPermission("4402")){removeElement("btVacDayOfListDayOfNew");removeElement("divVacationDayOfRegister")}
if(!checkPermission("4403")){removeElement("btVacDayOfRegCancelDayOf")}
VACATION_DAY_OF_NEW_ASSIGN=0;vacationDayOfList();employeeSearchOnLoad();employeeRegisterOnLoad();hideNotification()}
checkUserStatusAfterExecute(cdoLoad)}
function vacationDayOfNew(dayof){if(!isNaN(Number(dayof.dayofid))){setElementInnerHtml("h2VacDayOfRegHeader","Dados da dispensa")}else{setElementInnerHtml("h2VacDayOfRegHeader","Nova dispensa")}
disabledElement("txtVacDayOfRegStartDate");disabledElement("txtVacDayOfRegEndDate");if(dayof.dayofstatus==1){showParts("btVacDayOfRegCancelDayOf",!0)}else{hideParts("btVacDayOfRegCancelDayOf");if(dayof.dayofstatus==0){enabledElement("txtVacDayOfRegStartDate");enabledElement("txtVacDayOfRegEndDate")}}
showParts("divVacationDayOfRegister");setElementInnerHtml("lbVacDayOfRegDayOfId",dayof.dayofid);setElementInnerHtml("lbVacDayOfRegEmployeeId",dayof.employeeid);setElementInnerHtml("txtVacDayOfRegEmployeeName",dayof.employeename);setElementValue("txtVacDayOfRegStartDate",setLocalDate(dayof.dayofdate,10));setElementValue("txtVacDayOfRegEndDate",setLocalDate(dayof.dayofenddate,10));setElementValue("selVacDayOfRegAllowanceStatus",dayof.allowancestatus);setElementValue("txtVacDayOfRegReason",dayof.reason);setElementInnerHtml("lbVacDayOfRegPhotoOld",dayof.dayofphoto);setElementInnerHtml("aVacDayOfRegPhoto",dayof.dayofphoto);setElementAttribute("aVacDayOfRegPhoto","href",dayof.photo);setElementInnerHtml("lbVacDayOfRegUpdate","Cadastrado por "+getOperatorName(dayof.operatorEntry,dayof.entryuser)+" em "+setLocalDate(dayof.entrydate,16)+". <br>"+"Actualizado por "+getOperatorName(dayof.operatorName,dayof.statususer)+" em "+setLocalDate(dayof.statusdate,16));var iFrameUp=document.getElementById("iframeVacDayOfRegUploadJustify");iFrameUp.src+="&a"+randomString(3)+"="+randomString(3)}
function vacationDayOfSave(nextStatus=-1){if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();FILTER.dayofid=getElementInnerHTML("lbVacDayOfRegDayOfId");FILTER.employeeid=getElementInnerHTML("lbVacDayOfRegEmployeeId");FILTER.dayofdate=getElementValue("txtVacDayOfRegStartDate");FILTER.dayofenddate=getElementValue("txtVacDayOfRegEndDate");FILTER.allowancestatus=getElementValue("selVacDayOfRegAllowanceStatus");FILTER.dayofstatus=nextStatus;FILTER.reason=reviewString(document.getElementById("txtVacDayOfRegReason")).toUpperCase();FILTER.dayofphotoOld=getElementInnerHTML("lbVacDayOfRegPhotoOld");FILTER.dayofphoto=getElementInnerHTML("aVacDayOfRegPhoto");var mandatoryField=!1;var msg="";if(FILTER.employeeid==""){mandatoryField=!0;msg+="Deve indicar o trabalhador. <br>"}
if(FILTER.dayofdate==""){mandatoryField=!0;msg+="Deve indicar a data da dispensa. <br>"}
if(FILTER.dayofenddate==""){mandatoryField=!0;msg+="Deve indicar a data da dispensa. <br>"}
if(new Date(FILTER.dayofdate).getTime()>new Date(FILTER.dayofenddate).getTime()){mandatoryField=!0;msg+="A data de início da dispensa não pode ser superior a data de término. <br>"}
if(FILTER.reason==""){mandatoryField=!0;msg+="Deve indicar o motivo da dispensa. <br>"}
if(ST_SRH_WAITING_SERVER==1){mandatoryField=!0;msg+="Aguardando resposta do servidor. <br>"}
if(mandatoryField){alert(msg);return!1}
showNotification();ST_SRH_WAITING_SERVER=1;var http=new XMLHttpRequest();var params="action=saveVacationDayOf"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_VACATION_X;http.open('POST',url,!0);http.setRequestHeader('Content-type','application/x-www-form-urlencoded');http.onreadystatechange=function(){if(http.readyState==4&&http.status==200){ST_SRH_WAITING_SERVER=0;var result=validateSession(http);if(result.status==!0){showNotification(result.msg,1);hideParts("divVacationDayOfRegister");if(ST_SRH_MAIN_WHO_CALL=="VACDAYOFLIST"){vacationDayOfList(FILTER.employeeid)}
setElementInnerHtml("lbVacDayOfRegEmployeeId");setElementValue("lbVacDayOfRegDayOfId")}else{showNotification(result.msg,0)}}};http.send(params)}
function vacationDayOfReceiveMessage(event){var response=event.data;if(response.status==1){showNotification(response.msg,1);if(response.wc=="VACDAYOFLIST"){setElementInnerHtml("aVacDayOfRegPhoto",response.tempfile);var aPhoto=document.getElementById("aVacDayOfRegPhoto");aPhoto.href=URL_SRH_TEMP_FILE_X+response.tempfile}}else{showNotification(response.msg,0)}}
function vacationDayOfList(employeeId=-1){if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();FILTER.dependencyId=getElementValue("selVacDayOfListDependency");FILTER.employeeId=employeeId;FILTER.filterByDate=getElementChecked("chbVacDayOfListShowDate");FILTER.initialDate=getElementValue('txtVacDayOfListInitialDate');FILTER.endDate=getElementValue('txtVacDayOfListEndDate');FILTER.sex=getElementValue("selVacDayOfListSex");FILTER.nationality=getElementValue("selVacDayOfListCountry");FILTER.departmentId=getElementValue("selVacDayOfListDepartment");FILTER.categoryId=getElementValue("selVacDayOfListEmployeeCategory");let tableRef=document.getElementById("tblVacDayOfListMainTable");tableRef.innerHTML=strFilterResult();var http=new XMLHttpRequest();var params="action=getVacationDayOfList"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_VACATION_X;http.open('POST',url,!0);http.setRequestHeader('Content-type','application/x-www-form-urlencoded');http.onreadystatechange=function(){if(http.readyState==4&&http.status==200){var response=validateSession(http);var totalItems=response.length;if(totalItems>0){hideDivFilter()}
var numPagNumber=document.getElementById("numResultPageNumber");var numItems=document.getElementById("numResultItems");numPagNumber.value=1;setResultTotalPages(numPagNumber.id,numItems.id,totalItems,result);function result(){tableRef.innerHTML=strFilterResult(response);var pageNumber=Number(numPagNumber.value);var items=Number(numItems.value);var startIdx=(pageNumber-1)*items;var endIdx=startIdx+items;if(endIdx>totalItems){endIdx=totalItems}
setElementInnerHtml('lbResultOnList',endIdx+" / "+totalItems);var nRows=startIdx;for(var i=startIdx;i<endIdx;i++){let dayof=JSON.parse(response[i]);nRows+=1;let newRow=tableRef.insertRow(-1);newRow.setAttribute("id","rowVacDayOfListRow"+dayof.dayofid);newRow.setAttribute("class","borderGray"+setSelectedRowBackground("SELECTED_ROW_VACATION_DAYOF_LIST",newRow.id));let cellRow=createTableCell(newRow,nRows,"colRowNumber","#");let cellId=createTableCell(newRow,dayof.employeeid,"colProductId","Código");let cellName=createTableCell(newRow,dayof.employeename,"col-width-110 headcol","Nome completo");let cellCategory=createTableCell(newRow,dayof.category,"colProductId","Categoria / função");let cellDepart=createTableCell(newRow,dayof.department,"colProductId","Posto de trabalho");let cellDate=createTableCell(newRow,setLocalDate(dayof.dayofdate,10),"text-align-center","Início da dispensa");if(new Date(dayof.dayofdate).getTime()>new Date(dayof.dayofenddate).getTime()){dayof.dayofenddate=dayof.dayofdate}
let cellEndDate=createTableCell(newRow,setLocalDate(dayof.dayofenddate,10),"text-align-center","Fim da dispensa");var status="Anulada";var color="";if(dayof.dayofstatus==1){status="Normal";color="lightgreen"}
let cellStatus=createTableCell(newRow,status,"text-align-center","Estado");cellStatus.style.backgroundColor=color;let cellUpdate=createTableCell(newRow,setLocalDate(dayof.statusdate,16),"colProductId","Última actualização");let cellOper=createTableCell(newRow,getFirtLastName(dayof.operatorName)+" ("+dayof.statususer+")","colProductId","Operador");let cellAction=createTableCell(newRow,"","noPrint text-align-center","...");let btEdit=document.createElement("button");btEdit.setAttribute("class","labelEdit");btEdit.type="button";btEdit.onclick=function(){setSelectedRowOnClick(newRow,"SELECTED_ROW_VACATION_DAYOF_LIST");vacationDayOfNew(dayof)};cellAction.appendChild(btEdit);if(checkPermission("4002")){let btEdit=createElement("button","button","labelCustomer");btEdit.innerHTML="Trabalhador";btEdit.onclick=function(){setSelectedRowOnClick(newRow,"SELECTED_ROW_VACATION_DAYOF_LIST");employeeRegisterDetail(dayof.employeeid)};cellAction.appendChild(btEdit)}}
hideNotification()}
result()}};http.send(params)}
function vacationListOnLoad(){showNotification();setPageTitleWhoCall("4401-4402-4403","VACLIST","Lista de férias");function cdoLoad(){fillSelectDependencyFull("selVacListDependency",-1,1);fillSelectSex("selVacListSex",-1);fillSelectCountry("selVacListCountry",-1);fillSelectDepartment("selVacListDepartment",-1);fillSelectEmployeeCategory("selVacListEmployeeCategory",-1);setElementValue("txtVacListVacationYear",new Date().getFullYear());setTriggerButtonByText('txtVacListVacationYear','btVacListViewAll');if(!checkPermission("4002")){removeElement("btEmpLisNewEmployee");removeElement("divEmployeeRegister")}
if(!checkPermission("4111")){removeElement("btEmpWorSchRegWorkscheduleNew");removeElement("divWorkscheduleRegister")}
if(!checkPermission("4402")){removeElement("btVacListNewVacation");removeElement("divVacationRegister")}
if(!checkPermission("4403")){removeElement("btVacRegCancelVacation")}
document.getElementById("txtVacRegStartDate").onchange=function(){vacationRegisterCalculateEndTime()};document.getElementById("txtVacRegDuration").onchange=function(){vacationRegisterCalculateEndTime()};VACATION_NEW_ASSIGN=0;vacationList();employeeSearchOnLoad();employeeRegisterOnLoad();vacationRegisterOnLoad();hideNotification()}
checkUserStatusAfterExecute(cdoLoad)}
function vacationRegisterOnLoad(){fillSelectMonth("selPayRolLendRegReAllowanceMonth")}
function vacationNew(vacation){if(!isNaN(Number(vacation.vacationid))){setElementInnerHtml("h2VacRegHeader","Dados das férias")}else{setElementInnerHtml("h2VacRegHeader","Novas férias")}
if(vacation.vacationstatus==1){showParts("btVacRegVacationSave",!0);showParts("btVacRegCancelVacation",!0)}else{hideParts("btVacRegCancelVacation");if(vacation.vacationstatus==2){hideParts("btVacRegVacationSave")}else{showParts("btVacRegVacationSave",!0)}}
showParts("divVacationRegister");setElementInnerHtml("lbVacRegVacationId",vacation.vacationid);setElementInnerHtml("lbVacRegEmployeeId",vacation.employeeid);setElementInnerHtml("txtVacRegEmployeeName",vacation.employeename);setElementValue("txtVacRegStartDate",setLocalDate(vacation.startdate,10));setElementValue("txtVacRegDuration",vacation.duration);setElementInnerHtml("lbVacRegVacationStatus",vacationStatus(vacation.vacationstatus));setElementValue("txtVacRegAllowancePerc",vacation.allowanceperc);setElementValue("txtPayRolLendRegAllowanceYear",vacation.allowanceyear);setElementValue("selPayRolLendRegReAllowanceMonth",vacation.allowancemonth);setElementInnerHtml("lbVacRegUpdate","Cadastrado por "+getOperatorName(vacation.operatorEntry,vacation.entryuser)+" em "+setLocalDate(vacation.entrydate,16)+". <br>"+"Actualizado por "+getOperatorName(vacation.operatorName,vacation.statususer)+" em "+setLocalDate(vacation.statusdate,16));document.getElementById("txtVacRegDuration").dispatchEvent(new Event("change"))}
function vacationStatus(status){status=Number(status);if(status==2){return"Anulado"}else{return"Normal"}}
function vacationRegisterCalculateEndTime(){var startDate=new Date(getElementValue("txtVacRegStartDate"));var duration=Number(getElementValue("txtVacRegDuration"));var endDate=dateAddDays(startDate,duration);setElementInnerHtml("lbVacRegEndDate",setLocalDate(endDate,10))}
function vacationSave(nextStatus=-1){if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();FILTER.vacationid=getElementInnerHTML("lbVacRegVacationId");FILTER.employeeid=getElementInnerHTML("lbVacRegEmployeeId");FILTER.startdate=getElementValue("txtVacRegStartDate");FILTER.duration=getElementValue("txtVacRegDuration");FILTER.enddate=getElementInnerHTML("lbVacRegEndDate");FILTER.allowanceperc=getElementValue("txtVacRegAllowancePerc");FILTER.allowanceyear=getElementValue("txtPayRolLendRegAllowanceYear");FILTER.allowancemonth=getElementValue("selPayRolLendRegReAllowanceMonth");FILTER.vacationstatus=nextStatus;var mandatoryField=!1;var msg="";if(FILTER.employeeid==""){mandatoryField=!0;msg+="Deve indicar o trabalhador. <br>"}
if(ST_SRH_WAITING_SERVER==1){mandatoryField=!0;msg+="Aguardando resposta do servidor. <br>"}
if(mandatoryField){alert(msg);return!1}
showNotification();ST_SRH_WAITING_SERVER=1;var http=new XMLHttpRequest();var params="action=saveVacationInformation"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_VACATION_X;http.open('POST',url,!0);http.setRequestHeader('Content-type','application/x-www-form-urlencoded');http.onreadystatechange=function(){if(http.readyState==4&&http.status==200){ST_SRH_WAITING_SERVER=0;var result=validateSession(http);if(result.status==!0){showNotification(result.msg,1);hideParts("divVacationRegister");if(ST_SRH_MAIN_WHO_CALL=="VACLIST"){vacationList(FILTER.employeeid)}
setElementInnerHtml("lbVacRegEmployeeId")}else{showNotification(result.msg,0)}}};http.send(params)}
function vacationList(employeeId=-1){if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();FILTER.dependencyId=getElementValue("selVacListDependency");FILTER.employeeId=employeeId;FILTER.year=getElementValue('txtVacListVacationYear');FILTER.sex=getElementValue("selVacListSex");FILTER.nationality=getElementValue("selVacListCountry");FILTER.departmentId=getElementValue("selVacListDepartment");FILTER.categoryId=getElementValue("selVacListEmployeeCategory");let tableRef=document.getElementById("tblVacListMainTable");tableRef.innerHTML=strFilterResult();var http=new XMLHttpRequest();var params="action=getVacationList"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_VACATION_X;http.open('POST',url,!0);http.setRequestHeader('Content-type','application/x-www-form-urlencoded');http.onreadystatechange=function(){if(http.readyState==4&&http.status==200){var response=validateSession(http);var totalItems=response.length;if(totalItems>0){hideDivFilter()}
var numPagNumber=document.getElementById("numResultPageNumber");var numItems=document.getElementById("numResultItems");numPagNumber.value=1;setResultTotalPages(numPagNumber.id,numItems.id,totalItems,result);function result(){tableRef.innerHTML=strFilterResult(response);var pageNumber=Number(numPagNumber.value);var items=Number(numItems.value);var startIdx=(pageNumber-1)*items;var endIdx=startIdx+items;if(endIdx>totalItems){endIdx=totalItems}
setElementInnerHtml('lbResultOnList',endIdx+" / "+totalItems);var nRows=startIdx;for(var i=startIdx;i<endIdx;i++){let dayof=JSON.parse(response[i]);nRows+=1;let newRow=tableRef.insertRow(-1);newRow.setAttribute("id","rowVacListRow"+dayof.vacationid);newRow.setAttribute("class","borderGray"+setSelectedRowBackground("SELECTED_ROW_VACATION_LIST",newRow.id));let cellRow=createTableCell(newRow,nRows,"colRowNumber","#");let cellId=createTableCell(newRow,dayof.employeeid,"colProductId","Código");let cellName=createTableCell(newRow,dayof.employeename,"col-width-110 headcol","Nome completo");let cellCategory=createTableCell(newRow,dayof.category,"colProductId","Categoria / função");let cellDepart=createTableCell(newRow,dayof.department,"colProductId","Posto de trabalho");var bgc=setBgcByDates(dayof.startdate,dayof.enddate);let cellStartDate=createTableCell(newRow,setLocalDate(dayof.startdate,10),"text-align-center colNoWrap "+bgc,"Data inicial");let cellEndDate=createTableCell(newRow,setLocalDate(dayof.enddate,10),"text-align-center colNoWrap "+bgc,"Data de término");var status="Anulada";var color="";if(dayof.vacationstatus==1){status="Normal";color="lightgreen"}
let cellStatus=createTableCell(newRow,status,"text-align-center","Estado");cellStatus.style.backgroundColor=color;let cellUpdate=createTableCell(newRow,setLocalDate(dayof.statusdate,16),"colProductId","Última actualização");let cellOper=createTableCell(newRow,getFirtLastName(dayof.operatorName)+" ("+dayof.statususer+")","colProductId","Operador");let cellAction=createTableCell(newRow,"","noPrint text-align-center","...");let btEdit=document.createElement("button");btEdit.setAttribute("class","labelEdit");btEdit.type="button";btEdit.onclick=function(){setSelectedRowOnClick(newRow,"SELECTED_ROW_VACATION_LIST");vacationNew(dayof)};cellAction.appendChild(btEdit);if(checkPermission("4002")){let btEdit=createElement("button","button","labelCustomer");btEdit.innerHTML="Trabalhador";btEdit.onclick=function(){setSelectedRowOnClick(newRow,"SELECTED_ROW_VACATION_LIST");employeeRegisterDetail(dayof.employeeid)};cellAction.appendChild(btEdit)}}
hideNotification()}
result()}};http.send(params)}
var TRAVEL_ON_DUTY_NEW_ASSIGN=0;function travelOnDutyListOnLoad(){showNotification();setPageTitleWhoCall("4401-4402-4403","TRAONDUTLIST","Lista de deslocações em serviço");function cdoLoad(){fillSelectDependencyFull("selTraOnDutListDependency",-1,1);fillSelectSex("selTraOnDutListSex",-1);fillSelectCountry("selTraOnDutListCountry",-1);fillSelectDepartment("selTraOnDutListDepartment",-1);fillSelectEmployeeCategory("selTraOnDutListEmployeeCategory",-1);var date=new Date();setElementValue("txtTraOnDutListInitialDate",setLocalDate(new Date(date.getFullYear(),date.getMonth(),1),10));setElementValue("txtTraOnDutListEndDate",setLocalDate(new Date(),10));setTriggerButtonByText('txtTraOnDutListInitialDate','btTraOnDutListViewAll');setTriggerButtonByText('txtTraOnDutListEndDate','btTraOnDutListViewAll');if(!checkPermission("4002")){removeElement("btEmpLisNewEmployee");removeElement("divEmployeeRegister")}
if(!checkPermission("4111")){removeElement("btEmpWorSchRegWorkscheduleNew");removeElement("divWorkscheduleRegister")}
if(!checkPermission("4402")){removeElement("btTraOnDutListDayOfNew");removeElement("divTravelOnDutyRegister")}
if(!checkPermission("4403")){removeElement("btVacDayOfRegCancelDayOf")}
TRAVEL_ON_DUTY_NEW_ASSIGN=0;travelOnDutyList();employeeSearchOnLoad();employeeRegisterOnLoad();travelOnDutyRegisterOnLoad();hideNotification()}
checkUserStatusAfterExecute(cdoLoad)}
function travelOnDutyRegisterOnLoad(){if(!setOnloadStatus("divTravelOnDutyRegister",travelOnDutyRegisterOnLoad)){return!1}
fillSelectProvince("txtTraOnDutRegProvinceSource",1,SYSTEM_USER_STATUS.provinceId);fillSelectProvince("txtTraOnDutRegProvinceTarget",1,SYSTEM_USER_STATUS.provinceId);fillSelectMunicipality("txtTraOnDutRegMunicipalitySource",SYSTEM_USER_STATUS.provinceId,1,SYSTEM_USER_STATUS.municipalityId);fillSelectMunicipality("txtTraOnDutRegMunicipalityTarget",SYSTEM_USER_STATUS.provinceId,-1,SYSTEM_USER_STATUS.municipalityId);document.getElementById("txtTraOnDutRegProvinceSource").onchange=function(){fillSelectMunicipality("txtTraOnDutRegMunicipalitySource",this.value,-1)};document.getElementById("txtTraOnDutRegProvinceTarget").onchange=function(){fillSelectMunicipality("txtTraOnDutRegMunicipalityTarget",this.value,-1)};document.getElementById("btTraOnDutRegPrint").onclick=function(){var title="Guia de marcha nº "+getElementInnerHTML("lbTraOnDutRegTravelOnDutyId");printPageA4(title,'',!0)}}
function travelOnDutyEdit(travelonduty){if(!isNaN(Number(travelonduty.travelondutyid))){setElementInnerHtml("h2TraOnDutRegHeader","Dados da deslocação");showParts("btTraOnDutRegPrint",!0)}else{setElementInnerHtml("h2TraOnDutRegHeader","Nova deslocação")}
disabledElement("txtTraOnDutRegStartDate");disabledElement("txtTraOnDutRegEndDate");if(travelonduty.travelondutystatus==1){showParts("btTraOnDutRegCancelDayOf",!0)}else{hideParts("btTraOnDutRegCancelDayOf");hideParts("btTraOnDutRegPrint");if(travelonduty.travelondutystatus==0){enabledElement("txtTraOnDutRegStartDate");enabledElement("txtTraOnDutRegEndDate")}}
showParts("divTravelOnDutyRegister");setElementInnerHtml("lbTraOnDutRegTravelOnDutyId",travelonduty.travelondutyid);setElementInnerHtml("lbTraOnDutRegEmployeeId",travelonduty.employeeid);setElementInnerHtml("lbTraOnDutRegEmployeeName",travelonduty.employeename);setElementInnerHtml("lbTraOnDutRegDocumentNumber",travelonduty.documentnnumber);setElementInnerHtml("lbTraOnDutRegCategory",travelonduty.category);setElementValue("txtTraOnDutRegProvinceSource",travelonduty.provincesourceid);fillSelectMunicipality("txtTraOnDutRegMunicipalitySource",travelonduty.provincesourceid,-1,travelonduty.municipalitysourceid);setElementValue("txtTraOnDutRegProvinceTarget",travelonduty.provincetargetid);fillSelectMunicipality("txtTraOnDutRegMunicipalityTarget",travelonduty.provincetargetid,-1,travelonduty.municipalitytargetid);setElementValue("txtTraOnDutRegReason",travelonduty.reason);setElementValue("txtTraOnDutRegStartDate",setLocalDate(travelonduty.startdate,10));setElementValue("txtTraOnDutRegEndDate",setLocalDate(travelonduty.enddate,10));setElementValue("selTraOnDutRegAllowanceStatus",travelonduty.allowancestatus);setElementInnerHtml("lbTraOnDutRegUpdate","Cadastrado por "+getOperatorName(travelonduty.operatorEntry,travelonduty.entryuser)+" em "+setLocalDate(travelonduty.entrydate,16)+". <br>"+"Actualizado por "+getOperatorName(travelonduty.operatorName,travelonduty.statususer)+" em "+setLocalDate(travelonduty.statusdate,16))}
function travelOnDutySave(nextStatus=-1){if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();FILTER.travelondutyid=getElementInnerHTML("lbTraOnDutRegTravelOnDutyId");FILTER.employeeid=getElementInnerHTML("lbTraOnDutRegEmployeeId");FILTER.provincesourceid=getElementValue("txtTraOnDutRegProvinceSource");FILTER.municipalitysourceid=getElementValue("txtTraOnDutRegMunicipalitySource");FILTER.provincetargetid=getElementValue("txtTraOnDutRegProvinceTarget");FILTER.municipalitytargetid=getElementValue("txtTraOnDutRegMunicipalityTarget");FILTER.reason=reviewString(document.getElementById("txtTraOnDutRegReason")).toUpperCase();FILTER.startdate=getElementValue("txtTraOnDutRegStartDate");FILTER.enddate=getElementValue("txtTraOnDutRegEndDate");FILTER.allowancestatus=getElementValue("selTraOnDutRegAllowanceStatus");FILTER.travelondutystatus=nextStatus;var mandatoryField=!1;var msg="";if(FILTER.employeeid==""){mandatoryField=!0;msg+="Deve indicar o trabalhador. <br>"}
if(FILTER.provincesourceid==-1){mandatoryField=!0;msg+="Deve indicar a província de origem. <br>"}
if(FILTER.municipalitysourceid==-1){mandatoryField=!0;msg+="Deve indicar o município de origem. <br>"}
if(FILTER.provincetargetid==-1){mandatoryField=!0;msg+="Deve indicar a província de destino. <br>"}
if(FILTER.startdate==""){mandatoryField=!0;msg+="Deve indicar a data da deslocação. <br>"}
if(FILTER.enddate==""){mandatoryField=!0;msg+="Deve indicar a data da deslocação. <br>"}
if(new Date(FILTER.startdate).getTime()>new Date(FILTER.enddate).getTime()){mandatoryField=!0;msg+="A data de início da deslocação não pode ser superior a data de término. <br>"}
if(ST_SRH_WAITING_SERVER==1){mandatoryField=!0;msg+="Aguardando resposta do servidor. <br>"}
if(mandatoryField){alert(msg);return!1}
showNotification();ST_SRH_WAITING_SERVER=1;var http=new XMLHttpRequest();var params="action=saveTravelOnDuty"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_VACATION_X;http.open('POST',url,!0);http.setRequestHeader('Content-type','application/x-www-form-urlencoded');http.onreadystatechange=function(){if(http.readyState==4&&http.status==200){ST_SRH_WAITING_SERVER=0;var result=validateSession(http);if(result.status==!0){showNotification(result.msg,1);hideParts("divTravelOnDutyRegister");if(ST_SRH_MAIN_WHO_CALL=="TRAONDUTLIST"){travelOnDutyList(FILTER.employeeid)}
setElementInnerHtml("lbTraOnDutRegEmployeeId")}else{showNotification(result.msg,0)}}};http.send(params)}
function travelOnDutyList(employeeId=-1){if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();FILTER.dependencyId=getElementValue("selTraOnDutListDependency");FILTER.employeeId=employeeId;FILTER.filterByDate=getElementChecked("chbTraOnDutListShowDate");FILTER.initialDate=getElementValue('txtTraOnDutListInitialDate');FILTER.endDate=getElementValue('txtTraOnDutListEndDate');FILTER.sex=getElementValue("selTraOnDutListSex");FILTER.nationality=getElementValue("selTraOnDutListCountry");FILTER.departmentId=getElementValue("selTraOnDutListDepartment");FILTER.categoryId=getElementValue("selTraOnDutListEmployeeCategory");let tableRef=document.getElementById("tblTraOnDutListMainTable");tableRef.innerHTML=strFilterResult();var http=new XMLHttpRequest();var params="action=getTravelOnDutyList"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_VACATION_X;http.open('POST',url,!0);http.setRequestHeader('Content-type','application/x-www-form-urlencoded');http.onreadystatechange=function(){if(http.readyState==4&&http.status==200){var response=validateSession(http);var totalItems=response.length;if(totalItems>0){hideDivFilter()}
var numPagNumber=document.getElementById("numResultPageNumber");var numItems=document.getElementById("numResultItems");numPagNumber.value=1;setResultTotalPages(numPagNumber.id,numItems.id,totalItems,result);function result(){tableRef.innerHTML=strFilterResult(response);var pageNumber=Number(numPagNumber.value);var items=Number(numItems.value);var startIdx=(pageNumber-1)*items;var endIdx=startIdx+items;if(endIdx>totalItems){endIdx=totalItems}
setElementInnerHtml('lbResultOnList',endIdx+" / "+totalItems);var nRows=startIdx;for(var i=startIdx;i<endIdx;i++){let dayof=JSON.parse(response[i]);nRows+=1;let newRow=tableRef.insertRow(-1);newRow.setAttribute("id","rowTraOnDutListRow"+dayof.travelondutyid);newRow.setAttribute("class","borderGray"+setSelectedRowBackground("SELECTED_ROW_TRAVEL_ON_DUTY_LIST",newRow.id));let cellRow=createTableCell(newRow,nRows,"colRowNumber","#");let cellId=createTableCell(newRow,dayof.employeeid,"colProductId","Código");let cellName=createTableCell(newRow,dayof.employeename,"col-width-110 headcol","Nome completo");let cellCategory=createTableCell(newRow,dayof.category,"colProductId","Categoria / função");let cellDepart=createTableCell(newRow,dayof.department,"colProductId","Posto de trabalho");let cellSource=createTableCell(newRow,dayof.provincesource+" / "+dayof.municipalitysource,"","Origem")
let cellTarget=createTableCell(newRow,dayof.provincetarget+" / "+dayof.municipalitytarget,"","Destino")
let cellDate=createTableCell(newRow,setLocalDate(dayof.startdate,10),"text-align-center","Início da deslocação");let cellEndDate=createTableCell(newRow,setLocalDate(dayof.enddate,10),"text-align-center","Fim da deslocação");var status="Anulada";var color="";if(dayof.travelondutystatus==1){status="Normal";color="lightgreen"}
let cellStatus=createTableCell(newRow,status,"text-align-center","Estado");cellStatus.style.backgroundColor=color;let cellUpdate=createTableCell(newRow,setLocalDate(dayof.statusdate,16),"colProductId","Última actualização");let cellOper=createTableCell(newRow,getFirtLastName(dayof.operatorName)+" ("+dayof.statususer+")","colProductId","Operador");let cellAction=createTableCell(newRow,"","noPrint text-align-center","...");let btEdit=document.createElement("button");btEdit.setAttribute("class","labelEdit");btEdit.type="button";btEdit.onclick=function(){setSelectedRowOnClick(newRow,"SELECTED_ROW_TRAVEL_ON_DUTY_LIST");travelOnDutyEdit(dayof)};cellAction.appendChild(btEdit);if(checkPermission("4002")){let btEdit=createElement("button","button","labelCustomer");btEdit.innerHTML="Trabalhador";btEdit.onclick=function(){setSelectedRowOnClick(newRow,"SELECTED_ROW_TRAVEL_ON_DUTY_LIST");employeeRegisterDetail(dayof.employeeid)};cellAction.appendChild(btEdit)}}
hideNotification()}
result()}};http.send(params)}
function myVacationListOnLoad(){showNotification();setPageTitleWhoCall("0000","VACLIST","Minhas férias");function cdoLoad(){setElementValue("txtVacListVacationYear",new Date().getFullYear());setTriggerButtonByText('txtVacListVacationYear','btVacListViewAll');myVacationList();hideNotification()}
checkUserStatusAfterExecute(cdoLoad)}
function myVacationList(){if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();FILTER.dependencyId=-1;FILTER.employeeId=SYSTEM_USER_STATUS.employeeId;FILTER.year=getElementValue('txtVacListVacationYear');FILTER.sex="";FILTER.nationality=-1;FILTER.departmentId=-1;FILTER.categoryId=-1;let tableRef=document.getElementById("tblVacListMainTable");tableRef.innerHTML=strFilterResult();var http=new XMLHttpRequest();var params="action=getVacationList"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_VACATION_X;http.open('POST',url,!0);http.setRequestHeader('Content-type','application/x-www-form-urlencoded');http.onreadystatechange=function(){if(http.readyState==4&&http.status==200){var response=validateSession(http);var totalItems=response.length;if(totalItems>0){hideDivFilter()}
var numPagNumber=document.getElementById("numResultPageNumber");var numItems=document.getElementById("numResultItems");numPagNumber.value=1;setResultTotalPages(numPagNumber.id,numItems.id,totalItems,result);function result(){tableRef.innerHTML=strFilterResult(response);var pageNumber=Number(numPagNumber.value);var items=Number(numItems.value);var startIdx=(pageNumber-1)*items;var endIdx=startIdx+items;if(endIdx>totalItems){endIdx=totalItems}
setElementInnerHtml('lbResultOnList',endIdx+" / "+totalItems);var nRows=startIdx;for(var i=startIdx;i<endIdx;i++){let dayof=JSON.parse(response[i]);nRows+=1;let newRow=tableRef.insertRow(-1);newRow.setAttribute("id","rowVacListRow"+dayof.vacationid);newRow.setAttribute("class","borderGray"+setSelectedRowBackground("SELECTED_ROW_VACATION_LIST",newRow.id));let cellRow=createTableCell(newRow,nRows,"colRowNumber","#");let cellId=createTableCell(newRow,dayof.employeeid,"colProductId","Código");let cellName=createTableCell(newRow,dayof.employeename,"col-width-110 headcol","Nome completo");let cellCategory=createTableCell(newRow,dayof.category,"colProductId","Categoria / função");let cellDepart=createTableCell(newRow,dayof.department,"colProductId","Posto de trabalho");var bgc=setBgcByDates(dayof.startdate,dayof.enddate);let cellStartDate=createTableCell(newRow,setLocalDate(dayof.startdate,10),"text-align-center colNoWrap "+bgc,"Data inicial");let cellEndDate=createTableCell(newRow,setLocalDate(dayof.enddate,10),"text-align-center colNoWrap "+bgc,"Data de término");var status="Anulada";var color="";if(dayof.vacationstatus==1){status="Normal";color="lightgreen"}
let cellStatus=createTableCell(newRow,status,"text-align-center","Estado");cellStatus.style.backgroundColor=color;let cellUpdate=createTableCell(newRow,setLocalDate(dayof.statusdate,16),"colProductId","Última actualização")}
hideNotification()}
result()}};http.send(params)}
function myVacationDayOfListOnLoad(){showNotification();setPageTitleWhoCall("0000","VACDAYOFLIST","Minhas Dispensas");function cdoLoad(){var date=new Date();setElementValue("txtVacDayOfListInitialDate",setLocalDate(new Date(date.getFullYear(),date.getMonth(),1),10));setElementValue("txtVacDayOfListEndDate",setLocalDate(new Date(),10));setTriggerButtonByText('txtVacDayOfListInitialDate','btVacDayOfListViewAll');setTriggerButtonByText('txtVacDayOfListEndDate','btVacDayOfListViewAll');myVacationDayOfList();hideNotification()}
checkUserStatusAfterExecute(cdoLoad)}
function myVacationDayOfList(){if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();FILTER.dependencyId=-1;FILTER.employeeId=SYSTEM_USER_STATUS.employeeId;FILTER.filterByDate=getElementChecked("chbVacDayOfListShowDate");FILTER.initialDate=getElementValue('txtVacDayOfListInitialDate');FILTER.endDate=getElementValue('txtVacDayOfListEndDate');FILTER.sex="";FILTER.nationality=-1;FILTER.departmentId=-1;FILTER.categoryId=-1;let tableRef=document.getElementById("tblVacDayOfListMainTable");tableRef.innerHTML=strFilterResult();var http=new XMLHttpRequest();var params="action=getVacationDayOfList"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_VACATION_X;http.open('POST',url,!0);http.setRequestHeader('Content-type','application/x-www-form-urlencoded');http.onreadystatechange=function(){if(http.readyState==4&&http.status==200){var response=validateSession(http);var totalItems=response.length;if(totalItems>0){hideDivFilter()}
var numPagNumber=document.getElementById("numResultPageNumber");var numItems=document.getElementById("numResultItems");numPagNumber.value=1;setResultTotalPages(numPagNumber.id,numItems.id,totalItems,result);function result(){tableRef.innerHTML=strFilterResult(response);var pageNumber=Number(numPagNumber.value);var items=Number(numItems.value);var startIdx=(pageNumber-1)*items;var endIdx=startIdx+items;if(endIdx>totalItems){endIdx=totalItems}
setElementInnerHtml('lbResultOnList',endIdx+" / "+totalItems);var nRows=startIdx;for(var i=startIdx;i<endIdx;i++){let dayof=JSON.parse(response[i]);nRows+=1;let newRow=tableRef.insertRow(-1);newRow.setAttribute("id","rowVacDayOfListRow"+dayof.dayofid);newRow.setAttribute("class","borderGray"+setSelectedRowBackground("SELECTED_ROW_VACATION_DAYOF_LIST",newRow.id));let cellRow=createTableCell(newRow,nRows,"colRowNumber","#");let cellId=createTableCell(newRow,dayof.employeeid,"colProductId","Código");let cellName=createTableCell(newRow,dayof.employeename,"col-width-110 headcol","Nome completo");let cellCategory=createTableCell(newRow,dayof.category,"colProductId","Categoria / função");let cellDepart=createTableCell(newRow,dayof.department,"colProductId","Posto de trabalho");let cellDate=createTableCell(newRow,setLocalDate(dayof.dayofdate,10),"text-align-center","Início da dispensa");if(new Date(dayof.dayofdate).getTime()>new Date(dayof.dayofenddate).getTime()){dayof.dayofenddate=dayof.dayofdate}
let cellEndDate=createTableCell(newRow,setLocalDate(dayof.dayofenddate,10),"text-align-center","Fim da dispensa");var status="Anulada";var color="";if(dayof.dayofstatus==1){status="Normal";color="lightgreen"}
let cellStatus=createTableCell(newRow,status,"text-align-center","Estado");cellStatus.style.backgroundColor=color;let cellUpdate=createTableCell(newRow,setLocalDate(dayof.statusdate,16),"colProductId","Última actualização")}
hideNotification()}
result()}};http.send(params)}
function myTravelOnDutyListOnLoad(){showNotification();setPageTitleWhoCall("0000","TRAONDUTLIST","Minhas deslocações em serviço");function cdoLoad(){var date=new Date();setElementValue("txtTraOnDutListInitialDate",setLocalDate(new Date(date.getFullYear(),date.getMonth(),1),10));setElementValue("txtTraOnDutListEndDate",setLocalDate(new Date(),10));setTriggerButtonByText('txtTraOnDutListInitialDate','btTraOnDutListViewAll');setTriggerButtonByText('txtTraOnDutListEndDate','btTraOnDutListViewAll');myTravelOnDutyList();hideNotification()}
checkUserStatusAfterExecute(cdoLoad)}
function myTravelOnDutyList(){if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();FILTER.dependencyId=-1;FILTER.employeeId=SYSTEM_USER_STATUS.employeeId;FILTER.filterByDate=getElementChecked("chbTraOnDutListShowDate");FILTER.initialDate=getElementValue('txtTraOnDutListInitialDate');FILTER.endDate=getElementValue('txtTraOnDutListEndDate');FILTER.sex="";FILTER.nationality=-1;FILTER.departmentId=-1;FILTER.categoryId=-1;let tableRef=document.getElementById("tblTraOnDutListMainTable");tableRef.innerHTML=strFilterResult();var http=new XMLHttpRequest();var params="action=getTravelOnDutyList"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_VACATION_X;http.open('POST',url,!0);http.setRequestHeader('Content-type','application/x-www-form-urlencoded');http.onreadystatechange=function(){if(http.readyState==4&&http.status==200){var response=validateSession(http);var totalItems=response.length;if(totalItems>0){hideDivFilter()}
var numPagNumber=document.getElementById("numResultPageNumber");var numItems=document.getElementById("numResultItems");numPagNumber.value=1;setResultTotalPages(numPagNumber.id,numItems.id,totalItems,result);function result(){tableRef.innerHTML=strFilterResult(response);var pageNumber=Number(numPagNumber.value);var items=Number(numItems.value);var startIdx=(pageNumber-1)*items;var endIdx=startIdx+items;if(endIdx>totalItems){endIdx=totalItems}
setElementInnerHtml('lbResultOnList',endIdx+" / "+totalItems);var nRows=startIdx;for(var i=startIdx;i<endIdx;i++){let dayof=JSON.parse(response[i]);nRows+=1;let newRow=tableRef.insertRow(-1);newRow.setAttribute("id","rowTraOnDutListRow"+dayof.travelondutyid);newRow.setAttribute("class","borderGray"+setSelectedRowBackground("SELECTED_ROW_TRAVEL_ON_DUTY_LIST",newRow.id));let cellRow=createTableCell(newRow,nRows,"colRowNumber","#");let cellId=createTableCell(newRow,dayof.employeeid,"colProductId","Código");let cellName=createTableCell(newRow,dayof.employeename,"col-width-110 headcol","Nome completo");let cellCategory=createTableCell(newRow,dayof.category,"colProductId","Categoria / função");let cellDepart=createTableCell(newRow,dayof.department,"colProductId","Posto de trabalho");let cellSource=createTableCell(newRow,dayof.provincesource+" / "+dayof.municipalitysource,"","Origem")
let cellTarget=createTableCell(newRow,dayof.provincetarget+" / "+dayof.municipalitytarget,"","Destino")
let cellDate=createTableCell(newRow,setLocalDate(dayof.startdate,10),"text-align-center","Início da deslocação");let cellEndDate=createTableCell(newRow,setLocalDate(dayof.enddate,10),"text-align-center","Fim da deslocação");var status="Anulada";var color="";if(dayof.travelondutystatus==1){status="Normal";color="lightgreen"}
let cellStatus=createTableCell(newRow,status,"text-align-center","Estado");cellStatus.style.backgroundColor=color;let cellUpdate=createTableCell(newRow,setLocalDate(dayof.statusdate,16),"colProductId","Última actualização")}
hideNotification()}
result()}};http.send(params)}