class _empDoc{constructor(documentid="Novo",employeeid=0,identificationdocument=0,documenttype="B.I",documentnnumber="",emissiondate="2022-01-01",expirydate="2025-01-01",photo="",status=1,changed=1){this.documentid=documentid;this.employeeid=employeeid;this.identificationdocument=identificationdocument;this.documenttype=documenttype;this.documentnnumber=documentnnumber;this.emissiondate=emissiondate;this.expirydate=expirydate;this.photo=photo;this.status=status;this.changed=changed}}
class _empContract{constructor(contractid="Novo",employeeid=0,categoryid=-1,startdate="2022-01-01",endtime=3,photo="",status=1,changed=1){this.contractid=contractid;this.employeeid=employeeid;this.categoryid=categoryid;this.startdate=startdate;this.endtime=endtime;this.photo=photo;this.status=status;this.changed=changed}}
class _empCategory{constructor(currentcategoryid="Novo",employeeid=0,categoryid=-1,startdate="2022-01-01",status=1,changed=1){this.currentcategoryid=currentcategoryid;this.employeeid=employeeid;this.categoryid=categoryid;this.startdate=startdate;this.status=status;this.changed=changed}}
class _empWorkplace{constructor(workplaceid="Novo",employeeid=0,departmetid=-1,startdate="2022-01-01",status=1,changed=1){this.workplaceid=workplaceid;this.employeeid=employeeid;this.departmetid=departmetid;this.startdate=startdate;this.status=status;this.changed=changed}}
class _empWorkschedule{constructor(currentworkscheduleid="Novo",employeeid=0,temporarystatus=0,workscheduleid=-1,startdate="2022-01-01",enddate="2022-01-01",status=1,changed=1){this.currentworkscheduleid=currentworkscheduleid;this.employeeid=employeeid;this.workscheduleid=workscheduleid;this.startdate=startdate;this.status=status;this.changed=changed}}
class _empAcademic{constructor(academicid="Novo",employeeid=0,formationlevel=2,formation="",specialization="",startyear=2022,endyear="",school="",region="",status=1,changed=1){this.academicid=academicid;this.employeeid=employeeid;this.formationlevel=formationlevel;this.formation=formation;this.specialization=specialization;this.startyear=startyear;this.endyear=endyear;this.school=school;this.region=region;this.status=status;this.changed=changed}}
class _empTraining{constructor(trainingid="Novo",employeeid=0,formation="",startdate="2022-01-01",enddate="",school="",region="",status=1,changed=1){this.trainingid=trainingid;this.employeeid=employeeid;this.formation=formation;this.startdate=startdate;this.enddate=enddate;this.school=school;this.region=region;this.status=status;this.changed=changed}}
class _empBankAccount{constructor(accountid="Novo",employeeid=0,nationalbankid=-1,accountnumber="",iban="",startdate="2022-01-01",status=1,changed=1){this.accountid=accountid;this.employeeid=employeeid;this.nationalbankid=nationalbankid;this.accountnumber=accountnumber;this.iban=iban;this.startdate=startdate;this.status=status;this.changed=changed}}
function employeeCategoryOnLoad(){showNotification();setPageTitleWhoCall("4001-4002-4003","EMPCAT","Lista de catogorias / funções");function cdoLoad(){if(!checkPermission("4002")){removeElement("btEmpCatLisNewCategory");removeElement("divEmployeeCategoryRegister")}
if(!checkPermission("4202")){removeElement("btEmpCatRegAllowanceNew");removeElement("divPayrollAlloanceRegister")}
setAutoCompleteToFiel("txtEmpCatRegCategory",40,1);payrollAllowanceRegisterOnLoad();hideNotification()}
checkUserStatusAfterExecute(cdoLoad)}
function employeeCategoryNew(){employeeCategoryDetail()}
function employeeCategoryDetail(categoryId=-1){showParts("divEmployeeCategoryRegister");const lbHeader=document.getElementById("h2EmpCatRegHeader");const txtCategoryId=document.getElementById("txtEmpCatRegCategoryId");const txtCategory=document.getElementById("txtEmpCatRegCategory");const txtSalaryBase=document.getElementById("txtEmpCatRegBaseSalary");const selAttendence=document.getElementById("txtEmpCatRegAttendenceStatus");const lbUpdate=document.getElementById("lbEmpCatRegUpdate");PAYROLL_SCALE_ALLOWANCE_LIST=[];if(categoryId==-1){lbHeader.innerHTML="Nova categoria / função";txtCategoryId.value="Nova categoria / função *";txtCategory.value="";txtSalaryBase.value=0;selAttendence.value=1;lbUpdate.innerHTML="Actualizado em "+setLocalDate(new Date(),16);payrollScaleRegisterAllowanceList()}else{lbHeader.innerHTML="Dados da categoria / função";if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();FILTER.categoryId=categoryId;FILTER.startIdx=0;showNotification();var http=new XMLHttpRequest();var params="action=getEmployeeCategoryList"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_EMPLOYEE_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 categories=validateSession(http);let category=JSON.parse(categories[0]);txtCategoryId.value=category.categoryid;txtCategory.value=category.category;txtSalaryBase.value=category.salarybase;selAttendence.value=category.attendencestatus;lbUpdate.innerHTML="Cadastrado por "+getOperatorName(category.operatorEntry,category.entryuser)+" em "+setLocalDate(category.entrydate,16)+". <br>"+"Actualizado por "+getOperatorName(category.operatorName,category.statususer)+" em "+setLocalDate(category.statusdate,16);hideNotification();payrollScaleRegisterAllowanceList()}};http.send(params)}
setAutoCompleteToFiel("txtEmpCatRegCategory",40,1);if(!checkPermission("4202")){disabledElement(txtSalaryBase.id)}
txtCategory.focus()}
function employeeCategorySave(){if(!desktopSecurityCheck()){return!1}
var category=setFilterStatus();category.categoryid=getElementValue("txtEmpCatRegCategoryId");category.category=reviewString(document.getElementById("txtEmpCatRegCategory"));category.salarybase=getElementValue("txtEmpCatRegBaseSalary");category.attendencestatus=getElementValue("txtEmpCatRegAttendenceStatus");category.allawanceList=PAYROLL_SCALE_ALLOWANCE_LIST;var mandatoryField=!1;var msg="";if(category.category==""){mandatoryField=!0;msg+="Deve indicar a designação da categoria / função. <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=saveEmployeeCategoryInformation"+"&filterInfo="+JSON.stringify(category);var url=URL_SRH_EMPLOYEE_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("Categoria / função actualizada com sucessos.",1);hideParts("divEmployeeCategoryRegister");if(ST_SRH_MAIN_WHO_CALL=="EMPCAT"){employeeCategoryList()}else if(ST_SRH_MAIN_WHO_CALL=="PAYROLSCA"){payrollScaleList()}}else{showNotification(result.msg,0)}}};http.send(params)}
function employeeCategoryList(startIdx=0){if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();FILTER.companyId=SYSTEM_USER_STATUS.companyId;FILTER.categoryId=-1;FILTER.startIdx=startIdx;if(ST_SRH_WAITING_SERVER==1){showNotification("Aguardando resposta do servidor. <br>",0);return!1}
let tableRef=document.getElementById("tblEmpCatLisMainTable");if(FILTER.startIdx==0){tableRef.innerHTML=""}else{removeElement("rowEmpCatAddMore")}
showNotification();ST_SRH_WAITING_SERVER=1;var http=new XMLHttpRequest();var params="action=getEmployeeCategoryList"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_EMPLOYEE_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 categories=validateSession(http);tableRef.innerHTML+=strFilterResult(categories);setElementInnerHtml("lbResultOnList",FILTER.startIdx+categories.length);var nRows=startIdx;for(var i=0;i<categories.length;i++){let category=JSON.parse(categories[i]);nRows+=1;let newRow=tableRef.insertRow(-1);newRow.setAttribute("id","rowEmpCatList"+category.categoryid);newRow.setAttribute("class","borderGray"+setSelectedRowBackground("SELECTED_ROW_EMPLOYEE_CATEGORY_LIST",newRow.id));let cellRow=createTableCell(newRow,nRows,"colRowNumber","#");let cellId=createTableCell(newRow,category.categoryid,"colProductId","Código");let cellCategory=createTableCell(newRow,category.category,"","Categoria / função");let cellEdit=createTableCell(newRow,"","noPrint text-align-center","...");if(checkPermission("4002")){let btEdit=document.createElement("button");btEdit.setAttribute("class","labelEdit");btEdit.type="button";btEdit.name=category.categoryid;btEdit.onclick=function(){setSelectedRowOnClick(newRow,"SELECTED_ROW_EMPLOYEE_CATEGORY_LIST");employeeCategoryDetail(btEdit.name)};cellEdit.appendChild(btEdit)}
if(checkPermission("4003")){let btDelete=document.createElement("button");btDelete.setAttribute("class","labelDelete");btDelete.type="button";btDelete.onclick=function(){setSelectedRowOnClick(newRow,"SELECTED_ROW_EMPLOYEE_CATEGORY_LIST");employeeCategoryDelete(category.categoryid)};cellEdit.appendChild(btDelete)}}
if(categories.length>=FILTER.pageItems){let newRowC=tableRef.insertRow(-1);newRowC.id="rowEmpCatAddMore";newRowC.setAttribute("class","noPrint borderGray font-size-x-large text-align-center");newRowC.style.cursor="pointer";let cellDescription=newRowC.insertCell(-1);cellDescription.innerHTML="<b>VER MAIS...</b>";cellDescription.setAttribute("colspan","7");newRowC.onclick=function(){employeeCategoryList(FILTER.startIdx+FILTER.pageItems)}}
hideNotification()}};http.send(params)}
function employeeCategoryDelete(categoryId){function realDelete(){if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();FILTER.categoryId=categoryId;showNotification();var http=new XMLHttpRequest();var params="action=deleteEmployeeCategory"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_EMPLOYEE_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 result=validateSession(http);if(result.status==!0){showNotification(result.msg,1);employeeCategoryList()}else{showNotification(result.msg,0)}}};http.send(params)}
showConfirm("Tem a certeja que deseja apagar estas categoria / função?<br><br>",realDelete)}
function employeeListOnLoad(){showNotification();setPageTitleWhoCall("4001-4002-4003","EMPLIS","Lista de trabalhadores");function cdoLoad(){fillSelectDependencyFull("selEmpLisDependency",-1,1);fillSelectSex("selEmpLisSex",-1);fillSelectCountry("selEmpLisCountry",-1);fillSelectDepartment("selEmpLisDepartment",-1);fillSelectEmployeeCategory("selEmpLisEmployeeCategory",-1);var date=new Date();setElementValue("txtEmpLisInitialDate",setLocalDate(new Date(date.getFullYear(),date.getMonth(),1),10));setElementValue("txtEmpLisEndDate",setLocalDate(new Date(),10));setTriggerButtonByText('txtEmpLisInitialDate','btEmpLisViewAll');setTriggerButtonByText('txtEmpLisEndDate','btEmpLisViewAll');if(!checkPermission("4002")){removeElement("btEmpLisNewEmployee");removeElement("divEmployeeRegister")}
employeeSearchOnLoad();employeeRegisterOnLoad();hideNotification()}
checkUserStatusAfterExecute(cdoLoad)}
var EMPLOYEE_IDENTIFICATION_LIST=[];var EMPLOYEE_CONTRACT_LIST=[];var EMPLOYEE_CURRENT_CATEGORY_LIST=[];var EMPLOYEE_DEPARTMENT_LIST=[];var EMPLOYEE_WORKSCHEDULE_LIST=[];var EMPLOYEE_ACADEMIC_LIST=[];var EMPLOYEE_TRAINING_LIST=[];var EMPLOYEE_ACCOUNT_BANK_LIST=[];function employeeRegisterOnLoad(){if(!setOnloadStatus("divEmployeeRegister",employeeRegisterOnLoad)){return!1}
$(".float-right").each(function(){$(this).click(function(){if($(this).parent().attr("status")!=0){$(this).parent().trigger("click")}})});includeHtmlInHtml();fillSelectEmployeeStatus("selEmpRegEmployeeStatus",1,1);fillSelectDependencyFull("selEmpRegDependency",-1);fillSelectSalaryBaseSource("selEmpRegSalaryBaseSource",1,1);fillSelectIRTGroup("selEmpRegIRTGroup");fillSelectSystemUserBillingUser("selEmpRegNodeUser",-1,-1);fillSelectCountry("selEmpRegNationality");fillSelectCountry("selEmpRegBirthCountry");fillSelectSex("selEmpRegSex");fillSelectCivilStatus("selEmpRegMaritalStatus");setElementValue("txtEmpRegBirthDate",setLocalDate(new Date(),10));maskInputByPlaceHold('txtEmpRegPhone1');maskInputByPlaceHold('txtEmpRegPhone2');maskInputByPlaceHold('txtEmpRegPhone3');maskInputByPlaceHold('txtEmpRegContactPersonPhone');if(!checkPermission("4003")){removeElement("btEmpRegDelete")}
if(!checkPermission("4111")){removeElement("btEmpRegNewShift");removeElement("divWorkscheduleRegister")}
if(!checkPermission("4113")){removeElement("btEmpRegAddShift")}
if(!checkPermission("4106")){removeElement("btEmpRegNewBiometric");removeElement("divBiometricDeviceRegister")}
if(!checkPermission("4202")){disabledElement("selEmpRegSalaryBaseSource");disabledElement("txtEmpRegHoursPerMonth");disabledElement("txtEmpRegAmountPerHours");disabledElement("txtEmpRegSalaryBase")}
document.getElementById("selEmpRegSalaryBaseSource").onchange=function(){employeeRegisterSalaryBaseSourceOnChange()};document.getElementById("txtEmpRegHoursPerMonth").onchange=function(){employeeRegisterCalculateSalaryBase()};document.getElementById("txtEmpRegAmountPerHours").onchange=function(){employeeRegisterCalculateSalaryBase()};document.getElementById("txtEmpRegAmountPerTime").onchange=function(){employeeRegisterCalculateSalaryBase()};payrollAllowanceRegisterOnLoad();hideNotification()}
function employeeRegisterSalaryBaseSourceOnChange(){var salBaseSource=getElementValue("selEmpRegSalaryBaseSource");hideParts("divEmpRegHoursPerMonth");hideParts("divEmpRegAmountPerHours");hideParts("divEmpRegAmountPerTime");hideParts("divEmpRegSalaryBase");showParts("divEmpRegDefaulWorkDay",!0);disabledElement("txtEmpRegSalaryBase");setElementInnerHtml("lbEmpRegHoursPerMonth","Horas por mês:");if(salBaseSource==3){showParts("divEmpRegSalaryBase",!0);enabledElement("txtEmpRegSalaryBase")}else if(salBaseSource==2){showParts("divEmpRegHoursPerMonth",!0);showParts("divEmpRegAmountPerHours",!0);showParts("divEmpRegSalaryBase",!0);hideParts("divEmpRegDefaulWorkDay")}else if(salBaseSource==4){showParts("divEmpRegAmountPerHours",!0);hideParts("divEmpRegDefaulWorkDay")}else if(salBaseSource==5){setElementInnerHtml("lbEmpRegHoursPerMonth","Tempos por mês:");showParts("divEmpRegHoursPerMonth",!0);showParts("divEmpRegAmountPerTime",!0);showParts("divEmpRegSalaryBase",!0);hideParts("divEmpRegDefaulWorkDay")}}
function employeeRegisterCalculateSalaryBase(){var salBaseSource=getElementValue("selEmpRegSalaryBaseSource");var hoursMonth=Number(getElementValue("txtEmpRegHoursPerMonth"));var amountHours=Number(getElementValue("txtEmpRegAmountPerHours"));var amountTime=Number(getElementValue("txtEmpRegAmountPerTime"));var salBase=hoursMonth*amountHours;if(salBaseSource==5){salBase=hoursMonth*amountTime;var tHours=(hoursMonth*45)/60;amountHours=salBase/tHours;setElementValue("txtEmpRegAmountPerHours",amountHours.toFixed(2))}else{amountTime=(amountHours/60)*45}
setElementValue("txtEmpRegSalaryBase",salBase.toFixed(2))}
function employeeRegisterNew(){employeeRegisterDetail()}
function employeeRegisterDetail(employeeId=-1){showParts("divEmployeeRegister");const lbHeader=document.getElementById("h2EmpRegHeader");const txtEmployeeId=document.getElementById("txtEmpRegEmployeeId");const txtEmployeeName=document.getElementById("txtEmpRegEmployeeName");const txtAgentNumber=document.getElementById("txtEmpRegAgentNumber");const selEmpolyeeStatus=document.getElementById("selEmpRegEmployeeStatus");const selUserNode=document.getElementById("selEmpRegNodeUser");const selDependency=document.getElementById("selEmpRegDependency");const selSBaseSource=document.getElementById("selEmpRegSalaryBaseSource");const txtHourMotnh=document.getElementById("txtEmpRegHoursPerMonth");const txtAmountHours=document.getElementById("txtEmpRegAmountPerHours");const txtAmountTime=document.getElementById("txtEmpRegAmountPerTime");const txtSalaryBase=document.getElementById("txtEmpRegSalaryBase");const selDefaulWorkDay=document.getElementById("selEmpRegDefaulWorkDay");const selIRTGroup=document.getElementById("selEmpRegIRTGroup");const txtSSStatus=document.getElementById("txtEmpRegSSStatus");const selDefaulAttendenceStatus=document.getElementById("selEmpRegDefaultAttendenceStatus");const txtBirthDate=document.getElementById("txtEmpRegBirthDate");const selNationality=document.getElementById("selEmpRegNationality");const selBirthCountry=document.getElementById("selEmpRegBirthCountry");const txtBirthPlace=document.getElementById("txtEmpRegBirthPlace");const txtFather=document.getElementById("txtEmpRegFatherName");const txtMother=document.getElementById("txtEmpRegMotherName");const selSex=document.getElementById("selEmpRegSex");const selMaritalStatus=document.getElementById("selEmpRegMaritalStatus");const txtAddressCurrent=document.getElementById("txtEmpRegAddressCurrent");const txtAddressAlternative=document.getElementById("txtEmpRegAddressAlternative");const txtPhone1=document.getElementById("txtEmpRegPhone1");const txtPhone2=document.getElementById("txtEmpRegPhone2");const txtPhone3=document.getElementById("txtEmpRegPhone3");const txtEmail=document.getElementById("txtEmpRegEmail");const txtContactPerson=document.getElementById("txtEmpRegContactPerson");const txtKinshipDegree=document.getElementById("txtEmpRegKinshipDegree");const txtContactPersonPhone=document.getElementById("txtEmpRegContactPersonPhone");const txtContactPersonEmail=document.getElementById("txtEmpRegContactPersonEmail");const selBiometric=document.getElementById("selEmpRegBiometricoId");const txtBiometricIdetinfication=document.getElementById("txtEmpRegBiometricIdentification");const selAssignedCar=document.getElementById("selEmpRegAssignedCar");const lbUpdate=document.getElementById("lbEmpRegUpdate");cleanElement("tblEmpRegIdetinficationDocument");cleanElement("tblEmpRegContractStatus");cleanElement("tblEmpRegEmployeeCategory");cleanElement("tblEmpRegDepartment");cleanElement("tblEmpRegShift");cleanElement("tblEmpRegAcademicFormation");cleanElement("tblEmpRegProfitionalFormation");cleanElement("tblEmpRegBankAccount");EMPLOYEE_IDENTIFICATION_LIST=[];EMPLOYEE_CONTRACT_LIST=[];EMPLOYEE_CURRENT_CATEGORY_LIST=[];EMPLOYEE_DEPARTMENT_LIST=[];EMPLOYEE_WORKSCHEDULE_LIST=[];EMPLOYEE_ACADEMIC_LIST=[];EMPLOYEE_TRAINING_LIST=[];EMPLOYEE_ACCOUNT_BANK_LIST=[];if(employeeId==-1){lbHeader.innerHTML="Novo trabalhador";txtEmployeeId.value="Novo trabalhador *";txtEmployeeName.value="";txtAgentNumber.value="";selIRTGroup.value="A";txtSSStatus.value=1;selEmpolyeeStatus.value="1";selUserNode.value="-1";selDependency.value="-1";selSBaseSource.value="1";txtHourMotnh.value=0;txtAmountHours.value=0;txtAmountTime.value=0;txtSalaryBase.value=0;selDefaulWorkDay.value=1;selDefaulAttendenceStatus.value=1;selNationality.value=1;selBirthCountry.value=1;txtBirthPlace.value="";txtFather.value="";txtMother.value="";selSex.value="M";selMaritalStatus.value="S";txtAddressCurrent.value="";txtAddressAlternative.value="";txtPhone1.value="";txtPhone2.value="";txtPhone3.value="";txtEmail.value="";txtContactPerson.value="";txtKinshipDegree.value="";txtContactPersonPhone.value="";txtContactPersonEmail.value="";selAssignedCar.value=0;fillSelectBiometricDevice(selBiometric.id,-1);txtBiometricIdetinfication.value="";lbUpdate.innerHTML="Actualizado em "+setLocalDate(new Date(),16);dispatchOnInputChange();selSBaseSource.dispatchEvent(new Event('change'))}else{lbHeader.innerHTML="Dados do trabalhador";if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();FILTER.dependencyId=-1;FILTER.employeeId=employeeId;FILTER.filterByDate=0;FILTER.initialDate=setLocalDate(new Date(),10);FILTER.endDate=setLocalDate(new Date(),10);FILTER.sex="";FILTER.nationality=-1;FILTER.departmentId=-1;FILTER.categoryId=-1;FILTER.startIdx=0;showNotification();var http=new XMLHttpRequest();var params="action=getEmployeeList"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_EMPLOYEE_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 employees=validateSession(http);let employee=JSON.parse(employees[0]);console.log(employee);txtEmployeeId.value=employee.employeeid;txtEmployeeName.value=employee.employeename;txtAgentNumber.value=leadingZero(employee.agentnumberreal,4);selEmpolyeeStatus.value=employee.employeestatus;selUserNode.value=employee.nodeuser;selDependency.value=employee.dependencyid;selSBaseSource.value=employee.salarybasesource;txtHourMotnh.value=employee.hourspermonth;txtAmountHours.value=employee.amountperhour;txtAmountTime.value=((Number(employee.amountperhour)/60)*45).toFixed(2);txtSalaryBase.value=employee.salarybase;selDefaulWorkDay.value=employee.defaultworkday;selIRTGroup.value=employee.irtgroup;txtSSStatus.value=employee.ssstatus;selDefaulAttendenceStatus.value=employee.defaultattendencestatus;txtBirthDate.value=setLocalDate(employee.birthdate,10);selNationality.value=employee.nationality;selBirthCountry.value=employee.birthcountry;txtBirthPlace.value=employee.birthplace;txtFather.value=employee.fathername;txtMother.value=employee.mothername;selSex.value=employee.sex;selMaritalStatus.value=employee.maritalstatus;txtAddressCurrent.value=employee.addresscurrent;txtAddressAlternative.value=employee.addressalternative;txtPhone1.value=employee.phone1;txtPhone2.value=employee.phone2;txtPhone3.value=employee.phone3;txtEmail.value=employee.email;txtContactPerson.value=employee.contactperson;txtKinshipDegree.value=employee.kinshipdegree;txtContactPersonPhone.value=employee.contactpersonphone;txtContactPersonEmail.value=employee.contactpersonemail;selAssignedCar.value=employee.assignedcar;fillSelectBiometricDevice(selBiometric.id,-1,employee.biometricid);txtBiometricIdetinfication.value=employee.biometricidentification;lbUpdate.innerHTML="Cadastrado por "+getOperatorName(employee.operatorEntry,employee.entryuser)+" em "+setLocalDate(employee.entrydate,16)+". <br>"+"Actualizado por "+getOperatorName(employee.operatorName,employee.statususer)+" em "+setLocalDate(employee.statusdate,16);employeeRegisterIdentificationDocList(employeeId);employeeRegisterContractList(employeeId);employeeRegisterCategoryList(employeeId);employeeRegisterWorkplaceList(employeeId);employeeRegisterWorkscheduleList(employeeId);employeeRegisterAcademicList(employeeId);employeeRegisterTrainingList(employeeId);employeeRegisterBankAccountList(employeeId);dispatchOnInputChange();selSBaseSource.dispatchEvent(new Event('change'));hideNotification()}};http.send(params)}
setAutoCompleteToFiel(txtEmployeeName.id,41,1);setAutoCompleteToFiel(txtAgentNumber.id,55,1);setAutoCompleteToFiel(txtBirthPlace.id,42,1);setAutoCompleteToFiel(txtFather.id,43,1);setAutoCompleteToFiel(txtMother.id,44,1);setAutoCompleteToFiel(txtAddressCurrent.id,45,1);setAutoCompleteToFiel(txtAddressAlternative.id,46,1);setAutoCompleteToFiel(txtContactPerson.id,47,1);setAutoCompleteToFiel(txtKinshipDegree.id,48,1);txtEmployeeName.focus()}
function employeeRegisterIdentificationDocList(employeeId){if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();FILTER.employeeId=employeeId;FILTER.identificationdocument=1;var http=new XMLHttpRequest();var params="action=getEmployeeDocumentList"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_EMPLOYEE_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 categories=validateSession(http);for(var i=0;i<categories.length;i++){let empDoc=JSON.parse(categories[i]);employeeRegisterIdentificationDocAddSingleLine(empDoc)}}};http.send(params)}
function employeeRegisterIdentificationDocNew(){var empDoc=new _empDoc();empDoc.identificationdocument=1;empDoc.documenttype=identificationDocumentList()[0];employeeRegisterIdentificationDocAddSingleLine(empDoc)}
function employeeRegisterIdentificationDocAddSingleLine(empDoc){let docLine=(_empDoc);docLine=empDoc;var tblDoc=document.getElementById("tblEmpRegIdetinficationDocument");let nRows=tblDoc.rows.length;EMPLOYEE_IDENTIFICATION_LIST[nRows]=docLine;let newRow=tblDoc.insertRow(-1);newRow.setAttribute("class","borderGray font-size-medium");let cellRow=createTableCell(newRow,nRows+1,"colRowNumber","#");let cellDocType=createTableCell(newRow);let selDocType=createElement("select","","col-width-110 font-size-medium");selDocType.setAttribute("id","selEmpRegIdentificationDocumentType"+nRows);selDocType.onchange=function(){employeeRegisterIdentificationOnChange(nRows,this.value,"documenttype")};cellDocType.appendChild(selDocType);fillSelectIdentificationDoc(selDocType.getAttribute("id"),1,docLine.documenttype);let cellNumber=createTableCell(newRow,"","");let txtNumber=createElement("input","text","col-width-80 font-size-medium");txtNumber.onchange=function(){employeeRegisterIdentificationOnChange(nRows,this.value,"documentnnumber")};txtNumber.value=docLine.documentnnumber;cellNumber.appendChild(txtNumber);let cellEmission=createTableCell(newRow,"","");let txtEmission=createElement("input","date","font-size-medium");txtEmission.onchange=function(){employeeRegisterIdentificationOnChange(nRows,this.value,"emissiondate")};txtEmission.value=setLocalDate(docLine.emissiondate,10);cellEmission.appendChild(txtEmission);let cellExpitation=createTableCell(newRow);let txtExpiration=createElement("input","date","font-size-medium");txtExpiration.onchange=function(){employeeRegisterIdentificationOnChange(nRows,this.value,"expirydate")};txtExpiration.value=setLocalDate(docLine.expirydate,10);cellExpitation.appendChild(txtExpiration);let cellAction=createTableCell(newRow,"","noPrint text-align-center");if(checkPermission("4002")){let btRemove=createElement("button","button","labelDelete");btRemove.onclick=function(){employeeRegisterIdentificationDocRemove(nRows,newRow)};cellAction.appendChild(btRemove)}}
function employeeRegisterIdentificationOnChange(nLine,strValue,field){EMPLOYEE_IDENTIFICATION_LIST[Number(nLine)][field]=strValue;EMPLOYEE_IDENTIFICATION_LIST[Number(nLine)].changed=1}
function employeeRegisterIdentificationDocRemove(nLine,row){EMPLOYEE_IDENTIFICATION_LIST[Number(nLine)].status=0;row.innerHTML=""}
function employeeRegisterContractList(employeeId){if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();FILTER.employeeId=employeeId;var http=new XMLHttpRequest();var params="action=getEmployeeContractList"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_EMPLOYEE_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);for(var i=0;i<response.length;i++){let empContract=JSON.parse(response[i]);employeeRegisterContractAddSingleLine(empContract)}}};http.send(params)}
function employeeRegisterContractNew(){employeeRegisterContractAddSingleLine(new _empContract())}
function employeeRegisterContractAddSingleLine(empContract){let contractLine=(_empContract);contractLine=empContract;var tblContract=document.getElementById("tblEmpRegContractStatus");let nRows=tblContract.rows.length;EMPLOYEE_CONTRACT_LIST[nRows]=contractLine;let newRow=tblContract.insertRow(-1);newRow.setAttribute("class","borderGray font-size-medium");let cellRow=createTableCell(newRow,nRows+1,"colRowNumber","#");let cellCod=createTableCell(newRow,contractLine.contractid,"colProductId");let cellCategory=createTableCell(newRow);let selCategory=createElement("select","","col-width-110 font-size-medium");selCategory.setAttribute("id","selEmpRegContract"+nRows);selCategory.onchange=function(){employeeRegisterContractOnChange(nRows,this.value,"categoryid")};cellCategory.appendChild(selCategory);fillSelectEmployeeCategory(selCategory.getAttribute("id"),-1,contractLine.categoryid);let cellStartDate=createTableCell(newRow,"","");let txtStartDate=createElement("input","date","font-size-medium");txtStartDate.onchange=function(){employeeRegisterContractOnChange(nRows,this.value,"startdate")};txtStartDate.value=setLocalDate(contractLine.startdate,10);cellStartDate.appendChild(txtStartDate);let cellEndTime=createTableCell(newRow,"","");let txtEndTime=createElement("input","number","col-width-30 font-size-medium");txtEndTime.min="0";txtEndTime.onchange=function(){employeeRegisterContractOnChange(nRows,this.value,"endtime")};txtEndTime.value=contractLine.endtime;cellEndTime.appendChild(txtEndTime);let cellAction=createTableCell(newRow,"","noPrint text-align-center");if(checkPermission("4002")){let btRemove=createElement("button","button","labelDelete");btRemove.onclick=function(){employeeRegisterContractRemove(nRows,newRow)};cellAction.appendChild(btRemove)}}
function employeeRegisterContractOnChange(nLine,strValue,field){EMPLOYEE_CONTRACT_LIST[Number(nLine)][field]=strValue;EMPLOYEE_CONTRACT_LIST[Number(nLine)].changed=1}
function employeeRegisterContractRemove(nLine,row){EMPLOYEE_CONTRACT_LIST[Number(nLine)].status=0;row.innerHTML=""}
function employeeRegisterCategoryList(employeeId){if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();FILTER.employeeId=employeeId;var http=new XMLHttpRequest();var params="action=getEmployeeCurrentCategoryList"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_EMPLOYEE_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);for(var i=0;i<response.length;i++){let empCategory=JSON.parse(response[i]);employeeRegisterCategoryAddSingleLine(empCategory)}}};http.send(params)}
function employeeRegisterCategoriaNew(){var empCategory=new _empCategory();empCategory.startdate=setLocalDate(new Date(),10);employeeRegisterCategoryAddSingleLine(empCategory)}
function employeeRegisterCategoryAddSingleLine(empCategory){let categoryLine=(_empCategory);categoryLine=empCategory;var tblCategory=document.getElementById("tblEmpRegEmployeeCategory");let nRows=tblCategory.rows.length;EMPLOYEE_CURRENT_CATEGORY_LIST[nRows]=categoryLine;let newRow=tblCategory.insertRow(-1);newRow.setAttribute("class","borderGray font-size-medium");let cellRow=createTableCell(newRow,nRows+1,"colRowNumber","#");let cellCategory=createTableCell(newRow);let selCategory=createElement("select","","col-width-110 font-size-medium");selCategory.setAttribute("id","selEmpRegCategory"+nRows);selCategory.onchange=function(){employeeRegisterCategoryOnChange(nRows,this.value,"categoryid")};cellCategory.appendChild(selCategory);fillSelectEmployeeCategory(selCategory.getAttribute("id"),-1,categoryLine.categoryid);let cellStartDate=createTableCell(newRow,"","");let txtStartDate=createElement("input","date","font-size-medium");txtStartDate.onchange=function(){employeeRegisterCategoryOnChange(nRows,this.value,"startdate")};txtStartDate.value=setLocalDate(categoryLine.startdate,10);cellStartDate.appendChild(txtStartDate);let cellAction=createTableCell(newRow,"","noPrint text-align-center");if(checkPermission("4002")){let btRemove=createElement("button","button","labelDelete");btRemove.onclick=function(){employeeRegisterCategoryRemove(nRows,newRow)};cellAction.appendChild(btRemove)}}
function employeeRegisterCategoryOnChange(nLine,strValue,field){EMPLOYEE_CURRENT_CATEGORY_LIST[Number(nLine)][field]=strValue;EMPLOYEE_CURRENT_CATEGORY_LIST[Number(nLine)].changed=1}
function employeeRegisterCategoryRemove(nLine,row){EMPLOYEE_CURRENT_CATEGORY_LIST[Number(nLine)].status=0;row.innerHTML=""}
function employeeRegisterWorkplaceList(employeeId){if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();FILTER.employeeId=employeeId;var http=new XMLHttpRequest();var params="action=getEmployeeWorkplaceList"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_EMPLOYEE_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);for(var i=0;i<response.length;i++){let empCategory=JSON.parse(response[i]);employeeRegisterWorkplaceAddSingleLine(empCategory)}}};http.send(params)}
function employeeRegisterWorkplaceNew(){employeeRegisterWorkplaceAddSingleLine(new _empWorkplace())}
function employeeRegisterWorkplaceAddSingleLine(empWorkplace){let workLine=(_empWorkplace);workLine=empWorkplace;var tblWorkplace=document.getElementById("tblEmpRegDepartment");let nRows=tblWorkplace.rows.length;EMPLOYEE_DEPARTMENT_LIST[nRows]=workLine;let newRow=tblWorkplace.insertRow(-1);newRow.setAttribute("class","borderGray font-size-medium");let cellRow=createTableCell(newRow,nRows+1,"colRowNumber","#");let cellDepartment=createTableCell(newRow);let selDepartment=createElement("select","","col-width-110 font-size-medium");selDepartment.setAttribute("id","selEmpRegDepartment"+nRows);selDepartment.onchange=function(){employeeRegisterWorkplaceOnChange(nRows,this.value,"departmetid")};cellDepartment.appendChild(selDepartment);fillSelectDepartment(selDepartment.getAttribute("id"),-1,workLine.departmetid);let cellStartDate=createTableCell(newRow,"","");let txtStartDate=createElement("input","date","font-size-medium");txtStartDate.onchange=function(){employeeRegisterWorkplaceOnChange(nRows,this.value,"startdate")};txtStartDate.value=setLocalDate(workLine.startdate,10);cellStartDate.appendChild(txtStartDate);let cellAction=createTableCell(newRow,"","noPrint text-align-center");if(checkPermission("4002")){let btRemove=createElement("button","button","labelDelete");btRemove.onclick=function(){employeeRegisterWorkplaceRemove(nRows,newRow)};cellAction.appendChild(btRemove)}}
function employeeRegisterWorkplaceOnChange(nLine,strValue,field){EMPLOYEE_DEPARTMENT_LIST[Number(nLine)][field]=strValue;EMPLOYEE_DEPARTMENT_LIST[Number(nLine)].changed=1}
function employeeRegisterWorkplaceRemove(nLine,row){EMPLOYEE_DEPARTMENT_LIST[Number(nLine)].status=0;row.innerHTML=""}
function employeeRegisterWorkscheduleList(employeeId){if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();FILTER.employeeId=employeeId;var http=new XMLHttpRequest();var params="action=getEmployeeWorkscheduleList"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_EMPLOYEE_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);for(var i=0;i<response.length;i++){employeeRegisterWorkscheduleAddSingleLine(JSON.parse(response[i]))}}};http.send(params)}
function employeeRegisterWorkscheduleNew(){var empWorkschedule=new _empWorkschedule();empWorkschedule.startdate=setLocalDate(new Date(),10);employeeRegisterWorkscheduleAddSingleLine(empWorkschedule)}
function employeeRegisterWorkscheduleAddSingleLine(empWorkschedule){let workLine=(_empWorkschedule);workLine=empWorkschedule;var tblWorkschedule=document.getElementById("tblEmpRegShift");let nRows=tblWorkschedule.rows.length;EMPLOYEE_WORKSCHEDULE_LIST[nRows]=workLine;let newRow=tblWorkschedule.insertRow(-1);newRow.setAttribute("class","borderGray font-size-medium");let cellRow=createTableCell(newRow,nRows+1,"colRowNumber","#");let cellWorkschedule=createTableCell(newRow);let selWorkschedule=createElement("select","","col-width-110 font-size-medium");selWorkschedule.setAttribute("id","selEmpRegWorkschedule"+nRows);selWorkschedule.onchange=function(){employeeRegisterWorkscheduleOnChange(nRows,this.value,"workscheduleid")};cellWorkschedule.appendChild(selWorkschedule);fillSelectWorkschedule(selWorkschedule.getAttribute("id"),-1,workLine.workscheduleid);let cellStartDate=createTableCell(newRow,"","");let txtStartDate=createElement("input","date","font-size-medium");txtStartDate.onchange=function(){employeeRegisterWorkscheduleOnChange(nRows,this.value,"startdate")};txtStartDate.value=setLocalDate(workLine.startdate,10);cellStartDate.appendChild(txtStartDate);let cellAction=createTableCell(newRow,"","noPrint text-align-center");if(checkPermission("4002")){let btRemove=createElement("button","button","labelDelete");btRemove.onclick=function(){employeeRegisterWorkscheduleRemove(nRows,newRow)};cellAction.appendChild(btRemove)}}
function employeeRegisterWorkscheduleOnChange(nLine,strValue,field){EMPLOYEE_WORKSCHEDULE_LIST[Number(nLine)][field]=strValue;EMPLOYEE_WORKSCHEDULE_LIST[Number(nLine)].changed=1}
function employeeRegisterWorkscheduleRemove(nLine,row){EMPLOYEE_WORKSCHEDULE_LIST[Number(nLine)].status=0;row.innerHTML=""}
function employeeRegisterAcademicList(employeeId){if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();FILTER.employeeId=employeeId;var http=new XMLHttpRequest();var params="action=getEmployeeAcademicList"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_EMPLOYEE_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);for(var i=0;i<response.length;i++){let empCategory=JSON.parse(response[i]);employeeRegisterAcademicAddSingleLine(empCategory)}}};http.send(params)}
function employeeRegisterAcademicNew(){employeeRegisterAcademicAddSingleLine(new _empAcademic())}
function employeeRegisterAcademicAddSingleLine(empAcademic){let academicLine=(_empAcademic);academicLine=empAcademic;var tblDoc=document.getElementById("tblEmpRegAcademicFormation");let nRows=tblDoc.rows.length;EMPLOYEE_ACADEMIC_LIST[nRows]=academicLine;let newRow=tblDoc.insertRow(-1);newRow.setAttribute("class","borderGray font-size-medium");let cellRow=createTableCell(newRow,nRows+1,"colRowNumber","#");let cellLevel=createTableCell(newRow);let selLevel=createElement("select","","col-width-80 font-size-medium");selLevel.setAttribute("id","selEmpRegAcademicumentType"+nRows);selLevel.onchange=function(){employeeRegisterAcademicOnChange(nRows,this.value,"formationlevel")};cellLevel.appendChild(selLevel);fillSelectAcademicDegree(selLevel.getAttribute("id"),1,academicLine.formationlevel);let cellFormation=createTableCell(newRow,"","");let txtFormation=createElement("input","text","col-width-110 font-size-medium");txtFormation.onchange=function(){employeeRegisterAcademicOnChange(nRows,this.value,"formation")};txtFormation.value=academicLine.formation;cellFormation.appendChild(txtFormation);let cellSpecialization=createTableCell(newRow);let txtSpecialization=createElement("input","text","col-width-80 font-size-medium");txtSpecialization.onchange=function(){employeeRegisterAcademicOnChange(nRows,this.value,"specialization")};txtSpecialization.value=academicLine.specialization;cellSpecialization.appendChild(txtSpecialization);let cellStartYear=createTableCell(newRow);let txtStartYear=createElement("input","number","font-size-medium","width: 60px;");txtStartYear.min=1950;txtStartYear.onchange=function(){employeeRegisterAcademicOnChange(nRows,this.value,"startyear")};txtStartYear.value=academicLine.startyear;cellStartYear.appendChild(txtStartYear);let cellEndYear=createTableCell(newRow);let txtEndYear=createElement("input","text","font-size-medium","width: 60px;");txtEndYear.onchange=function(){employeeRegisterAcademicOnChange(nRows,this.value,"endyear")};txtEndYear.value=academicLine.endyear;cellEndYear.appendChild(txtEndYear);let cellSchool=createTableCell(newRow);let txtSchool=createElement("input","text","col-width-80 font-size-medium");txtSchool.onchange=function(){employeeRegisterAcademicOnChange(nRows,this.value,"school")};txtSchool.value=academicLine.school;cellSchool.appendChild(txtSchool);let cellRegion=createTableCell(newRow,"","");let txtRegion=createElement("input","text","col-width-80 font-size-medium");txtRegion.onchange=function(){employeeRegisterAcademicOnChange(nRows,this.value,"region")};txtRegion.value=academicLine.region;cellRegion.appendChild(txtRegion);let cellAction=createTableCell(newRow,"","noPrint text-align-center");if(checkPermission("4002")){let btRemove=createElement("button","button","labelDelete");btRemove.onclick=function(){employeeRegisterAcademicRemove(nRows,newRow)};cellAction.appendChild(btRemove)}}
function employeeRegisterAcademicOnChange(nLine,strValue,field){EMPLOYEE_ACADEMIC_LIST[Number(nLine)][field]=strValue;EMPLOYEE_ACADEMIC_LIST[Number(nLine)].changed=1}
function employeeRegisterAcademicRemove(nLine,row){EMPLOYEE_ACADEMIC_LIST[Number(nLine)].status=0;row.innerHTML=""}
function employeeRegisterTrainingList(employeeId){if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();FILTER.employeeId=employeeId;var http=new XMLHttpRequest();var params="action=getEmployeeTrainingList"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_EMPLOYEE_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);for(var i=0;i<response.length;i++){let empTraining=JSON.parse(response[i]);employeeRegisterTrainingAddSingleLine(empTraining)}}};http.send(params)}
function employeeRegisterTrainingNew(){employeeRegisterTrainingAddSingleLine(new _empTraining)}
function employeeRegisterTrainingAddSingleLine(empTraining){let trainLine=(_empTraining);trainLine=empTraining;var tblTrain=document.getElementById("tblEmpRegProfitionalFormation");let nRows=tblTrain.rows.length;EMPLOYEE_TRAINING_LIST[nRows]=trainLine;let newRow=tblTrain.insertRow(-1);newRow.setAttribute("class","borderGray font-size-medium");let cellRow=createTableCell(newRow,nRows+1,"colRowNumber","#");let cellFormation=createTableCell(newRow,"","");let txtFormation=createElement("input","text","col-width-110 font-size-medium");txtFormation.onchange=function(){employeeRegisterTrainingOnChange(nRows,this.value,"formation")};txtFormation.value=trainLine.formation;cellFormation.appendChild(txtFormation);let cellStartDate=createTableCell(newRow);let txtStartDate=createElement("input","date","col-width-80 font-size-medium");txtStartDate.onchange=function(){employeeRegisterTrainingOnChange(nRows,this.value,"startdate")};txtStartDate.value=setLocalDate(trainLine.startdate,10);cellStartDate.appendChild(txtStartDate);let cellEndDate=createTableCell(newRow);let txtEndDate=createElement("input","text","col-width-80 font-size-medium");txtEndDate.onchange=function(){employeeRegisterTrainingOnChange(nRows,this.value,"enddate")};txtEndDate.value=setLocalDate(trainLine.enddate,10);cellEndDate.appendChild(txtEndDate);let cellSchool=createTableCell(newRow);let txtSchool=createElement("input","text","col-width-80 font-size-medium");txtSchool.onchange=function(){employeeRegisterTrainingOnChange(nRows,this.value,"school")};txtSchool.value=trainLine.school;cellSchool.appendChild(txtSchool);let cellRegion=createTableCell(newRow,"","");let txtRegion=createElement("input","text","col-width-80 font-size-medium");txtRegion.onchange=function(){employeeRegisterTrainingOnChange(nRows,this.value,"region")};txtRegion.value=trainLine.region;cellRegion.appendChild(txtRegion);let cellAction=createTableCell(newRow,"","noPrint text-align-center");if(checkPermission("4002")){let btRemove=createElement("button","button","labelDelete");btRemove.onclick=function(){employeeRegisterTrainingRemove(nRows,newRow)};cellAction.appendChild(btRemove)}}
function employeeRegisterTrainingOnChange(nLine,strValue,field){EMPLOYEE_TRAINING_LIST[Number(nLine)][field]=strValue;EMPLOYEE_TRAINING_LIST[Number(nLine)].changed=1}
function employeeRegisterTrainingRemove(nLine,row){EMPLOYEE_TRAINING_LIST[Number(nLine)].status=0;row.innerHTML=""}
function employeeRegisterBankAccountList(employeeId){if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();FILTER.employeeId=employeeId;var http=new XMLHttpRequest();var params="action=getEmployeeBankAccountList"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_EMPLOYEE_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);for(var i=0;i<response.length;i++){let empBankAccount=JSON.parse(response[i]);employeeRegisterBankAccountAddSingleLine(empBankAccount)}}};http.send(params)}
function employeeRegisterBankAccountNew(){var empBankAccount=new _empBankAccount();empBankAccount.startdate=setLocalDate(new Date(),10);employeeRegisterBankAccountAddSingleLine(empBankAccount)}
function employeeRegisterBankAccountAddSingleLine(empBankAccount){let accountLine=(_empBankAccount);accountLine=empBankAccount;var tblBankAccount=document.getElementById("tblEmpRegBankAccount");let nRows=tblBankAccount.rows.length;EMPLOYEE_ACCOUNT_BANK_LIST[nRows]=accountLine;let newRow=tblBankAccount.insertRow(-1);newRow.setAttribute("class","borderGray font-size-medium");let cellRow=createTableCell(newRow,nRows+1,"colRowNumber","#");let cellBank=createTableCell(newRow);let selBank=createElement("select","","col-width-110 font-size-medium");selBank.setAttribute("id","selEmpRegBank"+nRows);selBank.onchange=function(){employeeRegisterBankAccountOnChange(nRows,this.value,"nationalbankid")};cellBank.appendChild(selBank);fillSelectNationalBank(selBank.getAttribute("id"),1,accountLine.nationalbankid);let cellAccount=createTableCell(newRow);let txtAccount=createElement("input","text","col-width-110 font-size-medium");txtAccount.onchange=function(){employeeRegisterBankAccountOnChange(nRows,this.value,"accountnumber")};txtAccount.value=accountLine.accountnumber;cellAccount.appendChild(txtAccount);let cellIban=createTableCell(newRow,"","");let txtIban=createElement("input","text","col-width-110 font-size-medium");txtIban.onchange=function(){employeeRegisterBankAccountOnChange(nRows,this.value,"iban")};txtIban.value=accountLine.iban;cellIban.appendChild(txtIban);let cellStartDate=createTableCell(newRow,"","");let txtStartDate=createElement("input","date","font-size-medium");txtStartDate.onchange=function(){employeeRegisterBankAccountOnChange(nRows,this.value,"startdate")};txtStartDate.value=setLocalDate(accountLine.startdate,10);cellStartDate.appendChild(txtStartDate);let cellAction=createTableCell(newRow,"","noPrint text-align-center");if(checkPermission("4002")){let btRemove=createElement("button","button","labelDelete");btRemove.onclick=function(){employeeRegisterBankAccountRemove(nRows,newRow)};cellAction.appendChild(btRemove)}}
function employeeRegisterBankAccountOnChange(nLine,strValue,field){EMPLOYEE_ACCOUNT_BANK_LIST[Number(nLine)][field]=strValue;EMPLOYEE_ACCOUNT_BANK_LIST[Number(nLine)].changed=1}
function employeeRegisterBankAccountRemove(nLine,row){EMPLOYEE_ACCOUNT_BANK_LIST[Number(nLine)].status=0;row.innerHTML=""}
function employeeRegisterSave(){if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();var EMPLOYEE_NEW={};EMPLOYEE_NEW.employeeid=getElementValue("txtEmpRegEmployeeId");EMPLOYEE_NEW.employeename=reviewString(document.getElementById("txtEmpRegEmployeeName")).toUpperCase();EMPLOYEE_NEW.agentnumberreal=reviewString(document.getElementById("txtEmpRegAgentNumber")).toUpperCase();EMPLOYEE_NEW.employeestatus=getElementValue("selEmpRegEmployeeStatus");EMPLOYEE_NEW.nodeuser=getElementValue("selEmpRegNodeUser");EMPLOYEE_NEW.dependencyid=getElementValue("selEmpRegDependency");EMPLOYEE_NEW.salarybasesource=getElementValue("selEmpRegSalaryBaseSource");EMPLOYEE_NEW.hourspermonth=getElementValue("txtEmpRegHoursPerMonth");EMPLOYEE_NEW.amountperhour=getElementValue("txtEmpRegAmountPerHours");EMPLOYEE_NEW.salarybase=getElementValue("txtEmpRegSalaryBase");EMPLOYEE_NEW.defaultworkday=getElementValue("selEmpRegDefaulWorkDay");if((EMPLOYEE_NEW.salarybasesource!=1)&&(EMPLOYEE_NEW.salarybasesource!=3)){EMPLOYEE_NEW.defaultworkday=1}
EMPLOYEE_NEW.irtgroup=getElementValue("selEmpRegIRTGroup");EMPLOYEE_NEW.ssstatus=getElementValue("txtEmpRegSSStatus");EMPLOYEE_NEW.defaultattendencestatus=getElementValue("selEmpRegDefaultAttendenceStatus");EMPLOYEE_NEW.birthdate=getElementValue("txtEmpRegBirthDate");EMPLOYEE_NEW.nationality=getElementValue("selEmpRegNationality");EMPLOYEE_NEW.birthcountry=getElementValue("selEmpRegBirthCountry");EMPLOYEE_NEW.birthplace=reviewString(document.getElementById("txtEmpRegBirthPlace")).toUpperCase();EMPLOYEE_NEW.fathername=reviewString(document.getElementById("txtEmpRegFatherName")).toUpperCase();EMPLOYEE_NEW.mothername=reviewString(document.getElementById("txtEmpRegMotherName")).toUpperCase();EMPLOYEE_NEW.sex=getElementValue("selEmpRegSex");EMPLOYEE_NEW.maritalstatus=getElementValue("selEmpRegMaritalStatus");EMPLOYEE_NEW.addresscurrent=reviewString(document.getElementById("txtEmpRegAddressCurrent")).toUpperCase();EMPLOYEE_NEW.addressalternative=reviewString(document.getElementById("txtEmpRegAddressAlternative")).toUpperCase();EMPLOYEE_NEW.phone1=getElementValue("txtEmpRegPhone1").replace(/[^0-9]/g,"");EMPLOYEE_NEW.phone2=getElementValue("txtEmpRegPhone2").replace(/[^0-9]/g,"");EMPLOYEE_NEW.phone3=getElementValue("txtEmpRegPhone3").replace(/[^0-9]/g,"");EMPLOYEE_NEW.email=reviewEmail(getElementValue("txtEmpRegEmail"));EMPLOYEE_NEW.contactperson=reviewString(document.getElementById("txtEmpRegContactPerson")).toUpperCase();EMPLOYEE_NEW.kinshipdegree=reviewString(document.getElementById("txtEmpRegKinshipDegree")).toUpperCase();EMPLOYEE_NEW.contactpersonphone=getElementValue("txtEmpRegContactPersonPhone").replace(/[^0-9]/g,"");EMPLOYEE_NEW.contactpersonemail=reviewEmail(getElementValue("txtEmpRegContactPersonEmail"));EMPLOYEE_NEW.biometricid=getElementValue("selEmpRegBiometricoId");EMPLOYEE_NEW.biometricidentification=reviewString(document.getElementById("txtEmpRegBiometricIdentification")).toUpperCase();EMPLOYEE_NEW.assignedcar=getElementValue("selEmpRegAssignedCar");EMPLOYEE_NEW.userId=SYSTEM_USER_STATUS.userId;FILTER.employeeInfo=EMPLOYEE_NEW;FILTER.identificationList=EMPLOYEE_IDENTIFICATION_LIST;FILTER.contractList=EMPLOYEE_CONTRACT_LIST;FILTER.categoryList=EMPLOYEE_CURRENT_CATEGORY_LIST;FILTER.departmentList=EMPLOYEE_DEPARTMENT_LIST;FILTER.workscheduleList=EMPLOYEE_WORKSCHEDULE_LIST;FILTER.academicList=EMPLOYEE_ACADEMIC_LIST;FILTER.trainingList=EMPLOYEE_TRAINING_LIST;FILTER.bankAccountList=EMPLOYEE_ACCOUNT_BANK_LIST;var mandatoryField=!1;var msg="";if(EMPLOYEE_NEW.employeename==""){mandatoryField=!0;msg+="Deve indicar o nome completo do 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=saveEmployeeSaveInformation"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_EMPLOYEE_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("Trabalhador guardado com sucesso.",1);hideParts("divEmployeeRegister");if(ST_SRH_MAIN_WHO_CALL=="EMPLIS"){employeeList()}else if(ST_SRH_MAIN_WHO_CALL=="EMPWORSCHLIS"){employeeWorkscheduleList(result.employeeId)}else if(ST_SRH_MAIN_WHO_CALL=="WORSCHWORSCH"){workscheduleWorkscheduleList(result.employeeId)}else if(ST_SRH_MAIN_WHO_CALL=="EMPBIODEV"){employeeBiometricDeviceList(result.employeeId)}else if(ST_SRH_MAIN_WHO_CALL=="POICONPOILIS"){pointControlPointList(result.employeeId)}else if(ST_SRH_MAIN_WHO_CALL=="VACDAYOFLIST"){vacationDayOfList(result.employeeId)}else if(ST_SRH_MAIN_WHO_CALL=="PAYROLPAYROLLIST"){if(isNaN(EMPLOYEE_NEW.employeeid)){payrollAddEmployee(result.employeeId)}else{payrollLoadEmployee(getElementValue("txtPayRollListPayrollId"))}}else if(ST_SRH_MAIN_WHO_CALL=="EMPCONSTALIST"){if(!isNaN(EMPLOYEE_NEW.employeeid)){employeeContractStatusList(result.employeeId)}else{employeeContractStatusList()}}else if(ST_SRH_MAIN_WHO_CALL=="EMPDOCSTALIST"){if(!isNaN(EMPLOYEE_NEW.employeeid)){employeeDocumentStatusList(result.employeeId)}else{employeeDocumentStatusList()}}else if(ST_SRH_MAIN_WHO_CALL=="EMPCURCATLIST"){if(!isNaN(EMPLOYEE_NEW.employeeid)){employeeAssignCategoryList(result.employeeId)}else{employeeAssignCategoryList()}}else if(ST_SRH_MAIN_WHO_CALL=="EMPDEPLIST"){if(!isNaN(EMPLOYEE_NEW.employeeid)){employeeDepartmentList(result.employeeId)}else{employeeDepartmentList()}}else if(ST_SRH_MAIN_WHO_CALL=="EMPBIODATALIST"){employeeBiographicDataList(result.employeeId)}else if(ST_SRH_MAIN_WHO_CALL=="EMPCONTLIST"){employeeContactList(result.employeeId)}else if(ST_SRH_MAIN_WHO_CALL=="EMPBANKLIST"){if(!isNaN(EMPLOYEE_NEW.employeeid)){employeeBankList(result.employeeId)}else{employeeBankList()}}
setAutoCompleteToFiel("txtEmpSearSearchEmployee",41,1)}else{showNotification(result.msg,0)}}};http.send(params)}
function employeeList(employeeId=-1,startIdx=0){if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();FILTER.dependencyId=getElementValue("selEmpLisDependency");FILTER.employeeId=employeeId;FILTER.filterByDate=getElementChecked("chbContrLisShowDate");FILTER.initialDate=getElementValue('txtEmpLisInitialDate');FILTER.endDate=getElementValue('txtEmpLisEndDate');FILTER.sex=getElementValue("selEmpLisSex");FILTER.nationality=getElementValue("selEmpLisCountry");FILTER.departmentId=getElementValue("selEmpLisDepartment");FILTER.categoryId=getElementValue("selEmpLisEmployeeCategory");FILTER.startIdx=startIdx;if(ST_SRH_WAITING_SERVER==1){showNotification("Aguardando resposta do servidor. <br>",0);return!1}
let tableRef=document.getElementById("employeeListOnLoad");if(FILTER.startIdx==0){tableRef.innerHTML=""}else{removeElement("rowEmpListRowAddMore")}
showNotification();ST_SRH_WAITING_SERVER=1;var http=new XMLHttpRequest();var params="action=getEmployeeList"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_EMPLOYEE_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 employees=validateSession(http);var totalItems=employees.length;if(totalItems>0){hideDivFilter()}
setElementInnerHtml('lbResultOnList',FILTER.startIdx+employees.length);function result(){tableRef.innerHTML+=strFilterResult(employees);var nRows=startIdx;for(var i=0;i<employees.length;i++){let employee=JSON.parse(employees[i]);nRows+=1;let newRow=tableRef.insertRow(-1);newRow.setAttribute("id","rowEmpList"+employee.employeeid);newRow.setAttribute("class","borderGray"+setSelectedRowBackground("SELECTED_ROW_EMPLOYEE_LIST",newRow.id));let cellRow=createTableCell(newRow,nRows,"colRowNumber","#");let cellId=createTableCell(newRow,employee.employeeid,"colProductId","Código");let cellAgent=createTableCell(newRow,leadingZero(employee.agentnumberreal,4),"colProductId","Nº de agente");let cellName=createTableCell(newRow,employee.employeename,"","Nome completo");let cellAge=createTableCell(newRow,Math.round(employee.age),"text-align-center","Idade (anos)");let cellSex=createTableCell(newRow,employee.sex,"text-align-center","Sexo");let cellNat=createTableCell(newRow,employee.countryName,"","Nacionalidade");let cellCategory=createTableCell(newRow,employee.category,"","Categoria / função");let cellDepart=createTableCell(newRow,employee.department,"","Posto de trabalho");let cellUpdate=createTableCell(newRow,setLocalDate(employee.statusdate,16),"colProductId","Última actualização");let cellOper=createTableCell(newRow,getFirtLastName(employee.operatorName)+" ("+employee.statususer+")","colProductId","Operador");let cellEdit=createTableCell(newRow,"","noPrint text-align-center","...");if(checkPermission("4002")){let btEdit=document.createElement("button");btEdit.setAttribute("class","labelEdit");btEdit.type="button";btEdit.name=employee.employeeid;btEdit.onclick=function(){setSelectedRowOnClick(newRow,"SELECTED_ROW_EMPLOYEE_LIST");employeeRegisterDetail(btEdit.name)};cellEdit.appendChild(btEdit)}}
if(employees.length>=FILTER.pageItems){let newRowC=tableRef.insertRow(-1);newRowC.id="rowEmpListRowAddMore";newRowC.setAttribute("class","noPrint borderGray font-size-x-large text-align-center");newRowC.style.cursor="pointer";let cellDescription=newRowC.insertCell(-1);cellDescription.innerHTML="<b>VER MAIS...</b>";cellDescription.setAttribute("colspan","7");newRowC.onclick=function(){employeeList(employeeId,FILTER.startIdx+FILTER.pageItems)}}
hideNotification()}
result()}};http.send(params)}
function sortSchedule(){EMPLOYEE_WORKSCHEDULE_LIST.sort(dynamicSort("startdate"))}
function employeeRegisterDelete(){function realDelete(){if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();FILTER.employeeId=getElementValue("txtEmpRegEmployeeId");showNotification();var http=new XMLHttpRequest();var params="action=deleteEmployee"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_EMPLOYEE_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 result=validateSession(http);if(result.status==!0){showNotification(result.msg,1);hideParts("divEmployeeRegister");if(ST_SRH_MAIN_WHO_CALL=="EMPLIS"){employeeList()}}else{showNotification(result.msg,0)}}};http.send(params)}
showConfirm("Tem a certeja que deseja apagar este trabalhador?<br><br>",realDelete)}
var EMPLOYEE_WORKSCHEDULE_NEW_ASSIGN=0;function employeeWorkscheduleListOnLoad(){showNotification();setPageTitleWhoCall("4113","EMPWORSCHLIS","Aplicar turno ao trabalhador");function cdoLoad(){fillSelectDependencyFull("selEmpWorSchListDependency",-1,1);fillSelectWorkschedule("selEmpWorSchListWorkschedule",-1);fillSelectCountry("selEmpWorSchListCountry",-1);fillSelectDepartment("selEmpWorSchListDepartment",-1);fillSelectEmployeeCategory("selEmpWorSchListEmployeeCategory",-1);fillSelectWorkscheduleAplicationType("selEmpWorSchRegAplicationType",1,0);var date=new Date();setElementValue("txtEmpWorSchListInitialDate",setLocalDate(new Date(date.getFullYear(),date.getMonth(),1),10));setElementValue("txtEmpWorSchListEndDate",setLocalDate(new Date(),10));setTriggerButtonByText('txtEmpWorSchListInitialDate','btEmpWorSchListViewAll');setTriggerButtonByText('txtEmpWorSchListEndDate','btEmpWorSchListViewAll');if(!checkPermission("4002")){removeElement("btEmpLisNewEmployee");removeElement("divEmployeeRegister")}
if(!checkPermission("4111")){removeElement("btEmpWorSchRegWorkscheduleNew");removeElement("divWorkscheduleRegister")}
document.getElementById("btEmpWorSchListImport").onclick=function(){employeeScheduleImportNew()};window.addEventListener('message',employeeScheduleImportReceiveMessage,!1);EMPLOYEE_WORKSCHEDULE_NEW_ASSIGN=0;employeeSearchOnLoad();employeeRegisterOnLoad();workscheduleSearchOnLoad();hideNotification()}
checkUserStatusAfterExecute(cdoLoad)}
function employeeWorkscheduleList(employeeId=-1,startIdx=0){if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();FILTER.dependencyId=getElementValue("selEmpWorSchListDependency");FILTER.employeeId=employeeId;FILTER.filterByDate=getElementChecked("chbEmpWorSchShowDate");FILTER.initialDate=getElementValue('txtEmpWorSchListInitialDate');FILTER.endDate=getElementValue('txtEmpWorSchListEndDate');FILTER.workscheduleId=getElementValue("selEmpWorSchListWorkschedule");FILTER.nationality=getElementValue("selEmpWorSchListCountry");FILTER.departmentId=getElementValue("selEmpWorSchListDepartment");FILTER.categoryId=getElementValue("selEmpWorSchListEmployeeCategory");FILTER.startIdx=startIdx;FILTER.pageItems=5;let tableRef=document.getElementById("tblEmpWorSchListMainTable");if(FILTER.startIdx==0){tableRef.innerHTML=""}else{removeElement("rowEmpWorkSchAddMore")}
var http=new XMLHttpRequest();var params="action=getEmployeeWorkscheduleListFull"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_EMPLOYEE_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()}
setElementInnerHtml('lbResultOnList',FILTER.startIdx+response.length);function result(){tableRef.innerHTML+=strFilterResult(response);var nRows=startIdx;for(var i=0;i<response.length;i++){let workschedule=JSON.parse(response[i]);nRows+=1;let newRow=tableRef.insertRow(-1);newRow.setAttribute("id","rowEmpWorSchListRow"+workschedule.currentworkscheduleid);newRow.setAttribute("class","borderGray"+setSelectedRowBackground("SELECTED_ROW_EMPLOYEE_WORKSCHEDULE_LIST",newRow.id));let cellRow=createTableCell(newRow,nRows,"colRowNumber","#");let cellId=createTableCell(newRow,workschedule.employeeid,"colProductId","Código");let cellAgent=createTableCell(newRow,leadingZero(workschedule.agentnumberreal,4),"colProductId","Nº de agente");let cellName=createTableCell(newRow,workschedule.employeename,"col-width-110 headcol","Nome completo");let cellType=createTableCell(newRow,setWorkscheduleAplicationType(workschedule.temporarystatus),"text-align-center","Tipo de aplicação");let cellWork=createTableCell(newRow,workschedule.workschedule,"text-align-center","Turno");let cellDate=createTableCell(newRow,setLocalDate(workschedule.startdate,10),"colProductId","Data de aplicação");let cellEndDate=createTableCell(newRow,setLocalDate(workschedule.enddate,10),"colProductId","Fim de aplicação");let cellCategory=createTableCell(newRow,workschedule.category,"colProductId","Categoria / função");let cellDepart=createTableCell(newRow,workschedule.department,"colProductId","Posto de trabalho");let cellUpdate=createTableCell(newRow,setLocalDate(workschedule.statusdate,16),"colProductId","Última actualização");let cellOper=createTableCell(newRow,getFirtLastName(workschedule.operatorName)+" ("+workschedule.statususer+")","colProductId","Operador");let cellAction=createTableCell(newRow,"","noPrint text-align-center","...");let btEdit=document.createElement("button");btEdit.setAttribute("class","labelEdit");btEdit.type="button";btEdit.name=workschedule.currentworkscheduleid;btEdit.onclick=function(){setSelectedRowOnClick(newRow,"SELECTED_ROW_EMPLOYEE_WORKSCHEDULE_LIST");employeeWorscheduleCurrentNew(workschedule)};cellAction.appendChild(btEdit);let btDelete=document.createElement("button");btDelete.setAttribute("class","labelDelete");btDelete.type="button";btDelete.name=workschedule.currentworkscheduleid;btDelete.onclick=function(){setSelectedRowOnClick(newRow,"SELECTED_ROW_EMPLOYEE_WORKSCHEDULE_LIST");employeeWorscheduleCurrentDelete(btDelete.name)};cellAction.appendChild(btDelete);if(checkPermission("4002")){let btEdit=createElement("button","button","labelCustomer");btEdit.innerHTML="Trabalhador";btEdit.onclick=function(){setSelectedRowOnClick(newRow,"SELECTED_ROW_EMPLOYEE_WORKSCHEDULE_LIST");employeeRegisterDetail(workschedule.employeeid)};cellAction.appendChild(btEdit)}}
if(response.length>=FILTER.pageItems){let newRowC=tableRef.insertRow(-1);newRowC.id="rowEmpWorkSchAddMore";newRowC.setAttribute("class","noPrint borderGray font-size-x-large text-align-center");newRowC.style.cursor="pointer";let cellDescription=newRowC.insertCell(-1);cellDescription.innerHTML="<b>VER MAIS...</b>";cellDescription.setAttribute("colspan","7");newRowC.onclick=function(){employeeWorkscheduleList(employeeId,FILTER.startIdx+FILTER.pageItems)}}
hideNotification()}
result()}};http.send(params)}
function employeeWorscheduleCurrentDelete(currentWorkscheduleId){function realDelete(){if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();FILTER.currentWorkscheduleId=currentWorkscheduleId;showNotification();var http=new XMLHttpRequest();var params="action=deleteEmployeeCurrentWorkschedule"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_EMPLOYEE_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 result=validateSession(http);if(result.status==!0){showNotification(result.msg,1);employeeWorkscheduleList()}else{showNotification(result.msg,0)}}};http.send(params)}
showConfirm("Tem a certeja que deseja apagar estas aplicação?<br><br>",realDelete)}
function employeeWorscheduleCurrentNew(employeeInfo){showParts("divEmployeeWorkscheduleRegister");if(isNaN(Number(employeeInfo.currentworkscheduleid))){setElementInnerHtml("h2EmpWorSchRegHeader","Nova aplicação");enabledElement("selEmpWorSchRegAplicationType")}else{setElementInnerHtml("h2EmpWorSchRegHeader","Dados da aplicação");disabledElement("selEmpWorSchRegAplicationType")}
setElementInnerHtml("lbEmpWorSchRegCurrentWorkscheduleId",employeeInfo.currentworkscheduleid);setElementInnerHtml("lbEmpWorSchRegEmployeeId",employeeInfo.employeeid);setElementInnerHtml("txtEmpWorSchRegEmployeeName",employeeInfo.employeename);setElementValue("selEmpWorSchRegAplicationType",employeeInfo.temporarystatus);fillSelectWorkschedule("selEmpWorSchRegWorkschedule",-1,employeeInfo.workscheduleid);setElementValue("txtEmpWorSchRegStartDate",setLocalDate(employeeInfo.startdate,10));setElementValue("txtEmpWorSchRegEndDate",setLocalDate(employeeInfo.enddate,10));setElementFocus("selEmpWorSchRegWorkschedule");if(employeeInfo.temporarystatus==1){showParts("divEmpWorSchRegEndDate")}else{hideParts("divEmpWorSchRegEndDate")}}
function employeeWorkscheduleCurrentAplicationChange(){var type=getElementValue("selEmpWorSchRegAplicationType");if(type==1){showParts("divEmpWorSchRegEndDate")}else{hideParts("divEmpWorSchRegEndDate")}}
function employeeWorkscheduleCurrentSave(){if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();var EMPLOYEE_WORKSCHEDULE_NEW=new _empWorkschedule();EMPLOYEE_WORKSCHEDULE_NEW.sessionId=FILTER.sessionId;EMPLOYEE_WORKSCHEDULE_NEW.sdk=FILTER.sdk;EMPLOYEE_WORKSCHEDULE_NEW.companyId=SYSTEM_USER_STATUS.companyId;EMPLOYEE_WORKSCHEDULE_NEW.dependencyId=SYSTEM_USER_STATUS.workplaceId;EMPLOYEE_WORKSCHEDULE_NEW.userId=SYSTEM_USER_STATUS.userId;EMPLOYEE_WORKSCHEDULE_NEW.currentworkscheduleid=getElementInnerHTML("lbEmpWorSchRegCurrentWorkscheduleId");EMPLOYEE_WORKSCHEDULE_NEW.employeeid=getElementInnerHTML("lbEmpWorSchRegEmployeeId");EMPLOYEE_WORKSCHEDULE_NEW.temporarystatus=getElementValue("selEmpWorSchRegAplicationType");EMPLOYEE_WORKSCHEDULE_NEW.workscheduleid=getElementValue("selEmpWorSchRegWorkschedule");EMPLOYEE_WORKSCHEDULE_NEW.startdate=getElementValue("txtEmpWorSchRegStartDate");EMPLOYEE_WORKSCHEDULE_NEW.enddate=getElementValue("txtEmpWorSchRegEndDate");var mandatoryField=!1;var msg="";if(EMPLOYEE_WORKSCHEDULE_NEW.employeeid==""){mandatoryField=!0;msg+="Deve indicar o trabalhador. <br>"}
if(EMPLOYEE_WORKSCHEDULE_NEW.workscheduleid==-1){mandatoryField=!0;msg+="Deve indicar o turno. <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=saveEmployeeWorkschedule"+"&filterInfo="+JSON.stringify(EMPLOYEE_WORKSCHEDULE_NEW);var url=URL_SRH_EMPLOYEE_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("divEmployeeWorkscheduleRegister");if(ST_SRH_MAIN_WHO_CALL=="EMPWORSCHLIS"){employeeWorkscheduleList(EMPLOYEE_WORKSCHEDULE_NEW.employeeid)}else if(ST_SRH_MAIN_WHO_CALL=="WORSCHWORSCH"){workscheduleWorkscheduleList(EMPLOYEE_WORKSCHEDULE_NEW.employeeid)}
setElementInnerHtml("lbEmpWorSchRegEmployeeId");setElementValue("selEmpWorSchRegWorkschedule",-1)}else{showNotification(result.msg,0)}}};http.send(params)}
function employeeBiometricDeviceListOnLoad(){showNotification();setPageTitleWhoCall("4106","EMPBIODEV","Trabalhador / Biométrico");function cdoLoad(){fillSelectDependencyFull("selEmpBioDevListDependency",-1,1);fillSelectBiometricDevice("selEmpBioDevListCountry",-1);fillSelectWorkschedule("selEmpBioDevListWorkschedule",-1);fillSelectDepartment("selEmpBioDevListDepartment",-1);fillSelectEmployeeCategory("selEmpBioDevListEmployeeCategory",-1);fillSelectWorkscheduleAplicationType("selEmpWorSchRegAplicationType",1,0);if(!checkPermission("4002")){removeElement("btEmpLisNewEmployee");removeElement("divEmployeeRegister")}
if(!checkPermission("4111")){removeElement("btEmpWorSchRegWorkscheduleNew");removeElement("divWorkscheduleRegister")}
employeeSearchOnLoad();employeeRegisterOnLoad();hideNotification()}
checkUserStatusAfterExecute(cdoLoad)}
function employeeBiometricDeviceList(employeeId=-1,startIdx=0){if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();FILTER.dependencyId=getElementValue("selEmpBioDevListDependency");FILTER.employeeId=employeeId;FILTER.biometricId=getElementValue('selEmpBioDevListCountry');FILTER.workscheduleId=getElementValue('selEmpBioDevListWorkschedule');FILTER.departmentId=getElementValue("selEmpBioDevListDepartment");FILTER.categoryId=getElementValue("selEmpBioDevListEmployeeCategory");FILTER.startIdx=startIdx;if(ST_SRH_WAITING_SERVER==1){showNotification("Aguardando resposta do servidor. <br>",0);return!1}
let tableRef=document.getElementById("tblEmpBioDevListMainTable");if(FILTER.startIdx==0){tableRef.innerHTML=""}else{removeElement("rowEmpBioDevListAddMore")}
showNotification();ST_SRH_WAITING_SERVER=1;var http=new XMLHttpRequest();var params="action=getEmployeeBiometricList"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_EMPLOYEE_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 response=validateSession(http);var totalItems=response.length;if(totalItems>0){hideDivFilter()}
setElementInnerHtml('lbResultOnList',FILTER.startIdx+response.length);function result(){tableRef.innerHTML+=strFilterResult(response);var nRows=startIdx;for(var i=0;i<response.length;i++){let employee=JSON.parse(response[i]);nRows+=1;let newRow=tableRef.insertRow(-1);newRow.setAttribute("id","rowEmpBioDevList"+employee.employeeid);newRow.setAttribute("class","borderGray"+setSelectedRowBackground("SELECTED_ROW_EMPLOYEE_BIOMETRIC_LIST",newRow.id));let cellRow=createTableCell(newRow,nRows,"colRowNumber","#");let cellId=createTableCell(newRow,employee.employeeid,"colProductId","Código");let cellAgent=createTableCell(newRow,leadingZero(employee.agentnumberreal,4),"colProductId","Nº de agente");let cellName=createTableCell(newRow,employee.employeename,"headcol","Nome completo");let cellBio=createTableCell(newRow,employee.brand,"","Dispositivo biométrico");let cellIdentif=createTableCell(newRow,employee.biometricidentification,"text-align-center","Identificador Único");let cellWorkSche=createTableCell(newRow,employee.workschedule,"","Turno");let cellCategory=createTableCell(newRow,employee.category,"","Categoria / função");let cellDepart=createTableCell(newRow,employee.department,"","Posto de trabalho");let cellEdit=createTableCell(newRow,"","noPrint text-align-center","...");let btEdit=document.createElement("button");btEdit.setAttribute("class","labelEdit");btEdit.type="button";btEdit.name=employee.employeeid;btEdit.onclick=function(){setSelectedRowOnClick(newRow,"SELECTED_ROW_EMPLOYEE_BIOMETRIC_LIST");employeeBiometricDeviceEdit(employee)};cellEdit.appendChild(btEdit)}
if(response.length>=FILTER.pageItems){let newRowC=tableRef.insertRow(-1);newRowC.id="rowEmpBioDevListAddMore";newRowC.setAttribute("class","noPrint borderGray font-size-x-large text-align-center");newRowC.style.cursor="pointer";let cellDescription=newRowC.insertCell(-1);cellDescription.innerHTML="<b>VER MAIS...</b>";cellDescription.setAttribute("colspan","7");newRowC.onclick=function(){employeeBiometricDeviceList(employeeId,FILTER.startIdx+FILTER.pageItems)}}
hideNotification()}
result()}};http.send(params)}
function employeeBiometricDeviceEdit(employeeInfo){showParts("divEmployeeBiometricDeviceRegister");setElementInnerHtml("lbEmpBioDevRegEmployeeId",employeeInfo.employeeid);setElementInnerHtml("txtEmpBioDevRegEmployeeName",employeeInfo.employeename);fillSelectBiometricDevice("selEmpBioDevRegBiometric",-1,employeeInfo.biometricid);setElementValue("txtEmpBioDevRegBiometricIdentification",employeeInfo.biometricidentification);setElementFocus("txtEmpBioDevRegBiometricIdentification")}
function employeeBiometricDeviceSave(){if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();var EMPLOYEE_BIOMETRIC_NEW=new _empWorkschedule();EMPLOYEE_BIOMETRIC_NEW.sessionId=FILTER.sessionId;EMPLOYEE_BIOMETRIC_NEW.sdk=FILTER.sdk;EMPLOYEE_BIOMETRIC_NEW.companyId=SYSTEM_USER_STATUS.companyId;EMPLOYEE_BIOMETRIC_NEW.dependencyId=SYSTEM_USER_STATUS.workplaceId;EMPLOYEE_BIOMETRIC_NEW.userId=SYSTEM_USER_STATUS.userId;EMPLOYEE_BIOMETRIC_NEW.employeeid=getElementInnerHTML("lbEmpBioDevRegEmployeeId");EMPLOYEE_BIOMETRIC_NEW.biometricid=getElementValue("selEmpBioDevRegBiometric");EMPLOYEE_BIOMETRIC_NEW.biometricidentification=getElementValue("txtEmpBioDevRegBiometricIdentification");var mandatoryField=!1;var msg="";if(EMPLOYEE_BIOMETRIC_NEW.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=saveEmployeeBiometricDevice"+"&filterInfo="+JSON.stringify(EMPLOYEE_BIOMETRIC_NEW);var url=URL_SRH_EMPLOYEE_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("divEmployeeBiometricDeviceRegister");if(ST_SRH_MAIN_WHO_CALL=="EMPBIODEV"){employeeBiometricDeviceList(EMPLOYEE_BIOMETRIC_NEW.employeeid)}
setElementInnerHtml("lbEmpBioDevRegEmployeeId")}else{showNotification(result.msg,0)}}};http.send(params)}
var EMPLOYEE_CONTRACT_STATUS_NEW_ASSIGN=0;function employeeContractStatusListOnLoad(){showNotification();setPageTitleWhoCall("4001-4002-4003","EMPCONSTALIST","Situação contratual");function cdoLoad(){fillSelectDependencyFull("selEmpContrStaListDependency",-1,1);fillSelectSex("selEmpContrStaListSex",-1);fillSelectCountry("selEmpContrStaListCountry",-1);fillSelectDepartment("selEmpContrStaListDepartment",-1);fillSelectEmployeeCategory("selEmpContrStaListEmployeeCategory",-1);fillSelectEmployeeCategory("selEmpContrRegCategoryID",-1);var date=new Date();setElementValue("txtEmpContrStaListInitialDate",setLocalDate(new Date(date.getFullYear(),0,1),10));setElementValue("txtEmpContrStaListEndDate",setLocalDate(new Date(),10));setTriggerButtonByText('txtEmpContrStaListInitialDate','btEmpContrStaListViewAll');setTriggerButtonByText('txtEmpContrStaListEndDate','btEmpContrStaListViewAll');if(!checkPermission("4002")){removeElement("btEmpLisNewEmployee");removeElement("divEmployeeRegister");removeElement("btEmpContrStaListContractNew");removeElement("divEmployeeContractRegister")}
if(!checkPermission("4111")){removeElement("btEmpWorSchRegWorkscheduleNew");removeElement("divWorkscheduleRegister")}
if(!checkPermission("4403")){removeElement("btVacDayOfRegCancelDayOf")}
EMPLOYEE_CONTRACT_STATUS_NEW_ASSIGN=0;employeeSearchOnLoad();employeeRegisterOnLoad();hideNotification()}
checkUserStatusAfterExecute(cdoLoad)}
function employeeContractStatusList(employeeId=-1,startIdx=0){if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();FILTER.dependencyId=getElementValue("selEmpContrStaListDependency");FILTER.employeeId=employeeId;FILTER.filterByDate=getElementChecked("chbEmpContrStaListShowDate");FILTER.initialDate=getElementValue('txtEmpContrStaListInitialDate');FILTER.endDate=getElementValue('txtEmpContrStaListEndDate');FILTER.sex=getElementValue("selEmpContrStaListSex");FILTER.nationality=getElementValue("selEmpContrStaListCountry");FILTER.departmentId=getElementValue("selEmpContrStaListDepartment");FILTER.categoryId=getElementValue("selEmpContrStaListEmployeeCategory");FILTER.startIdx=startIdx;if(ST_SRH_WAITING_SERVER==1){showNotification("Aguardando resposta do servidor. <br>",0);return!1}
let tableRef=document.getElementById("tblEmpContrStaListMainTable");if(FILTER.startIdx==0){tableRef.innerHTML=""}else{removeElement("rowEmpContrListRowAddMore")}
showNotification();ST_SRH_WAITING_SERVER=1;var http=new XMLHttpRequest();var params="action=getEnployeeContractStatusList"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_EMPLOYEE_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 response=validateSession(http);var totalItems=response.length;if(totalItems>0){hideDivFilter()}
setElementInnerHtml('lbResultOnList',FILTER.startIdx+response.length);function result(){tableRef.innerHTML+=strFilterResult(response);var nRows=startIdx;for(var i=0;i<response.length;i++){let contract=JSON.parse(response[i]);nRows+=1;let newRow=tableRef.insertRow(-1);newRow.setAttribute("id","rowEmpConStaListRow"+contract.contractid);newRow.setAttribute("class","borderGray"+setSelectedRowBackground("SELECTED_ROW_EMPLOYEE_CONTRACT_LIST",newRow.id));let cellRow=createTableCell(newRow,nRows,"colRowNumber","#");let cellId=createTableCell(newRow,contract.employeeid,"colProductId","Código");let cellAgent=createTableCell(newRow,leadingZero(contract.agentnumberreal,4),"colProductId","Nº de agente");let cellName=createTableCell(newRow,contract.employeename,"col-width-110 headcol","Nome completo");let cellHomeTime=createTableCell(newRow,contract.hometime,"colProductId","Anos de trabalho");let cellCategory=createTableCell(newRow,contract.category,"colProductId","Categoria / função");let cellDepart=createTableCell(newRow,contract.department,"colProductId","Posto de trabalho");var bgc=setBgcByDates(contract.startdate,contract.validate);let cellDate=createTableCell(newRow,setLocalDate(contract.startdate,10),"text-align-center colNoWrap "+bgc,"Início do contrato");let cellEndTime=createTableCell(newRow,contract.endtime,"text-align-center ","Duração (meses)");var validate=(isNaN(contract.endtime))?contract.endtime:setLocalDate(contract.validate,10);let cellValidate=createTableCell(newRow,validate,"text-align-center colNoWrap "+bgc,"Validade");let cellAttach=createTableCell(newRow,"","colProductId");if(contract.photo!=""){let aAttach=document.createElement("a");aAttach.href=contract.photopath;aAttach.target="blank";aAttach.innerHTML="Ver";cellAttach.appendChild(aAttach)}
let cellUpdate=createTableCell(newRow,setLocalDate(contract.statusdate,16),"colProductId","Última actualização");let cellOper=createTableCell(newRow,getFirtLastName(contract.operatorName)+" ("+contract.statususer+")","colProductId","Operador");let cellAction=createTableCell(newRow,"","noPrint text-align-center","...");if(checkPermission("4002")){let btEdit=createElement("button","button","labelEdit");btEdit.onclick=function(){setSelectedRowOnClick(newRow,"SELECTED_ROW_EMPLOYEE_CONTRACT_LIST");employeeContractStatusRegisterNew(contract)};cellAction.appendChild(btEdit);let btDelete=createElement("button","button","labelDelete");btDelete.onclick=function(){setSelectedRowOnClick(newRow,"SELECTED_ROW_EMPLOYEE_CONTRACT_LIST");employeeContractStatusDelete(contract)};cellAction.appendChild(btDelete);let btEmp=createElement("button","button","labelCustomer");btEmp.innerHTML="Trabalhador";btEmp.onclick=function(){setSelectedRowOnClick(newRow,"SELECTED_ROW_EMPLOYEE_CONTRACT_LIST");employeeRegisterDetail(contract.employeeid)};cellAction.appendChild(btEmp)}}
if(response.length>=FILTER.pageItems){let newRowC=tableRef.insertRow(-1);newRowC.id="rowEmpContrListRowAddMore";newRowC.setAttribute("class","noPrint borderGray font-size-x-large text-align-center");newRowC.style.cursor="pointer";let cellDescription=newRowC.insertCell(-1);cellDescription.innerHTML="<b>VER MAIS...</b>";cellDescription.setAttribute("colspan","7");newRowC.onclick=function(){employeeContractStatusList(employeeId,FILTER.startIdx+FILTER.pageItems)}}
hideNotification()}
result()}};http.send(params)}
function employeeContractRegisterReceiveMessage(event){var response=event.data;if(response.status==1){showNotification(response.msg,1);if(response.wc=="EMPCATSTAREG"){setElementInnerHtml("aEmpContrRegPhoto",response.tempfile);var aPhoto=document.getElementById("aEmpContrRegPhoto");aPhoto.href=URL_SRH_TEMP_FILE_X+response.tempfile}}else{showNotification(response.msg,0)}}
function employeeContractStatusRegisterNew(contract){if(!isNaN(Number(contract.contractid))){setElementInnerHtml("h2EmpContrRegHeader","Dados do contrato")}else{setElementInnerHtml("h2EmpContrRegHeader","Novo contrato")}
showParts("divEmployeeContractRegister");setElementInnerHtml("lbEmpContrRegContractId",contract.contractid);setElementInnerHtml("lbEmpContrRegEmployeeId",contract.employeeid);setElementInnerHtml("txtEmpContrRegEmployeeName",contract.employeename);setElementValue("txtEmpContrRegStartDate",setLocalDate(contract.startdate,10));setElementValue("selEmpContrRegCategoryID",contract.categoryid);setElementValue("txtEmpContrRegEndTime",contract.endtime);setElementValue("txtEmpContrRegDispathNumber",contract.dispatchnumber);setElementInnerHtml("lbEmpContrRegPhotoOld",contract.photo);setElementInnerHtml("aEmpContrRegPhoto",contract.photo);setElementAttribute("aEmpContrRegPhoto","href",contract.photopath);setElementInnerHtml("lbEmpContrRegUpdate","Cadastrado por "+getOperatorName(contract.operatorEntry,contract.entryuser)+" em "+setLocalDate(contract.entrydate,16)+". <br>"+"Actualizado por "+getOperatorName(contract.operatorName,contract.statususer)+" em "+setLocalDate(contract.statusdate,16));var ifr=document.getElementById("iframeEmpContrRegUploadAttach");ifr.src+="&a"+randomString(3)+"="+randomString(3);dispatchOnInputChange()}
function employeeContractStatusSave(){if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();FILTER.contractid=getElementInnerHTML("lbEmpContrRegContractId");FILTER.employeeid=getElementInnerHTML("lbEmpContrRegEmployeeId");FILTER.categoryid=getElementValue("selEmpContrRegCategoryID");FILTER.startdate=getElementValue("txtEmpContrRegStartDate");FILTER.endtime=getElementValue("txtEmpContrRegEndTime");FILTER.dispatchnumber=reviewString(document.getElementById("txtEmpContrRegDispathNumber"));FILTER.photoOld=getElementInnerHTML("lbEmpContrRegPhotoOld");FILTER.photo=getElementInnerHTML("aEmpContrRegPhoto");var mandatoryField=!1;var msg="";if(FILTER.employeeid==""){mandatoryField=!0;msg+="Deve indicar o trabalhador. <br>"}
if(FILTER.startdate==""){mandatoryField=!0;msg+="Deve indicar a data de início do contrato. <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=saveEmployeeContractStatus"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_EMPLOYEE_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("divEmployeeContractRegister");if(ST_SRH_MAIN_WHO_CALL=="EMPCONSTALIST"){employeeContractStatusList(result.employeeid)}
setElementInnerHtml("lbEmpContrRegEmployeeId")}else{showNotification(result.msg,0)}}};http.send(params)}
function employeeContractStatusDelete(contract){function realDelete(){if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();FILTER.contractid=contract.contractid;FILTER.photo=contract.photo;var mandatoryField=!1;var msg="";if(FILTER.employeeid==""){mandatoryField=!0;msg+="Deve indicar o trabalhador. <br>"}
if(FILTER.startdate==""){mandatoryField=!0;msg+="Deve indicar a data de início do contrato. <br>"}
if(mandatoryField){alert(msg);return!1}
showNotification();var http=new XMLHttpRequest();var params="action=deleteEmployeeContractStatus"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_EMPLOYEE_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 result=validateSession(http);if(result.status==!0){showNotification(result.msg,1);if(ST_SRH_MAIN_WHO_CALL=="EMPCONSTALIST"){employeeContractStatusList()}}else{showNotification(result.msg,0)}}};http.send(params)}
showConfirm("Tem a certeza que deseja apagar este contrato?",realDelete)}
var EMPLOYEE_DOCUMENT_STATUS_NEW_ASSIGN=0;function employeeDocumentStatusListOnLoad(){showNotification();setPageTitleWhoCall("4001-4002-4003","EMPDOCSTALIST","Situação documental");function cdoLoad(){fillSelectDependencyFull("selEmpDocStaListDependency",-1,1);fillSelectSex("selEmpDocStaListSex",-1);fillSelectCountry("selEmpDocStaListCountry",-1);fillSelectDepartment("selEmpDocStaListDepartment",-1);fillSelectEmployeeCategory("selEmpDocStaListEmployeeCategory",-1);fillSelectEmployeeCategory("selEmpContrRegCategoryID",-1);var date=new Date();setElementValue("txtEmpDocStaListInitialDate",setLocalDate(new Date(date.getFullYear(),0,1),10));setElementValue("txtEmpDocStaListEndDate",setLocalDate(new Date(),10));setTriggerButtonByText('txtEmpDocStaListInitialDate','btEmpDocStaListViewAll');setTriggerButtonByText('txtEmpDocStaListEndDate','btEmpDocStaListViewAll');if(!checkPermission("4002")){removeElement("btEmpLisNewEmployee");removeElement("divEmployeeRegister");removeElement("btEmpDocStaListDocumentNew");removeElement("divEmployeeContractRegister")}
if(!checkPermission("4111")){removeElement("btEmpWorSchRegWorkscheduleNew");removeElement("divWorkscheduleRegister")}
EMPLOYEE_DOCUMENT_STATUS_NEW_ASSIGN=0;employeeSearchOnLoad();employeeRegisterOnLoad();employeeDocumentStatusRegisterOnLoad();hideNotification()}
checkUserStatusAfterExecute(cdoLoad)}
function employeeDocumentStatusList(employeeId=-1,startIdx=0){if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();FILTER.dependencyId=getElementValue("selEmpDocStaListDependency");FILTER.employeeId=employeeId;FILTER.filterByDate=getElementChecked("chbEmpDocStaListShowDate");FILTER.initialDate=getElementValue('txtEmpDocStaListInitialDate');FILTER.endDate=getElementValue('txtEmpDocStaListEndDate');FILTER.sex=getElementValue("selEmpDocStaListSex");FILTER.nationality=getElementValue("selEmpDocStaListCountry");FILTER.departmentId=getElementValue("selEmpDocStaListDepartment");FILTER.categoryId=getElementValue("selEmpDocStaListEmployeeCategory");FILTER.startIdx=startIdx;if(ST_SRH_WAITING_SERVER==1){showNotification("Aguardando resposta do servidor. <br>",0);return!1}
let tableRef=document.getElementById("tblEmpDocStaListMainTable");if(FILTER.startIdx==0){tableRef.innerHTML=""}else{removeElement("rowEmpDocStaRowAddMore")}
showNotification();ST_SRH_WAITING_SERVER=1;var http=new XMLHttpRequest();var params="action=getEnployeeDocumentStatusList"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_EMPLOYEE_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 response=validateSession(http);var totalItems=response.length;if(totalItems>0){hideDivFilter()}
setElementInnerHtml('lbResultOnList',FILTER.startIdx+response.length);function result(){tableRef.innerHTML+=strFilterResult(response);var nRows=startIdx;for(var i=0;i<response.length;i++){let doc=JSON.parse(response[i]);nRows+=1;let newRow=tableRef.insertRow(-1);newRow.setAttribute("id","rowEmpDocStaListRow"+doc.documentid);newRow.setAttribute("class","borderGray"+setSelectedRowBackground("SELECTED_ROW_EMPLOYEE_DOCUMENT_LIST",newRow.id));let cellRow=createTableCell(newRow,nRows,"colRowNumber","#");let cellId=createTableCell(newRow,doc.employeeid,"colProductId","Código");let cellAgent=createTableCell(newRow,leadingZero(doc.agentnumberreal,4),"colProductId","Código");let cellName=createTableCell(newRow,doc.employeename,"col-width-110","Nome completo");let cellCategory=createTableCell(newRow,doc.category,"colProductId","Categoria / função");let cellDepart=createTableCell(newRow,doc.department,"colProductId","Posto de trabalho");let cellDocT=createTableCell(newRow,doc.documenttype,"","Tipo de documento");let cellDocNum=createTableCell(newRow,doc.documentnnumber,"","Nº");var bgc=setBgcByDates(doc.emissiondate,doc.expirydate);let cellDate=createTableCell(newRow,setLocalDate(doc.emissiondate,10),"text-align-center colNoWrap "+bgc,"Data de emissão");let cellValidate=createTableCell(newRow,setLocalDate(doc.expirydate,10),"text-align-center colNoWrap "+bgc,"Caducidade");let cellAttach=createTableCell(newRow,"","colProductId");if(doc.photo!=""){let aAttach=document.createElement("a");aAttach.href=doc.photopath;aAttach.target="blank";aAttach.innerHTML="Ver";cellAttach.appendChild(aAttach)}
let cellUpdate=createTableCell(newRow,setLocalDate(doc.statusdate,16),"colProductId","Última actualização");let cellOper=createTableCell(newRow,getFirtLastName(doc.operatorName)+" ("+doc.statususer+")","colProductId","Operador");let cellAction=createTableCell(newRow,"","noPrint text-align-center","...");if(checkPermission("4002")){let btEdit=createElement("button","button","labelEdit");btEdit.onclick=function(){setSelectedRowOnClick(newRow,"SELECTED_ROW_EMPLOYEE_DOCUMENT_LIST");employeeDocumentStatusRegisterNew(doc)};cellAction.appendChild(btEdit);let btDelete=createElement("button","button","labelDelete");btDelete.onclick=function(){setSelectedRowOnClick(newRow,"SELECTED_ROW_EMPLOYEE_DOCUMENT_LIST");employeeDocumentStatusDelete(doc)};cellAction.appendChild(btDelete);let btEmp=createElement("button","button","labelCustomer");btEmp.innerHTML="Trabalhador";btEmp.onclick=function(){setSelectedRowOnClick(newRow,"SELECTED_ROW_EMPLOYEE_DOCUMENT_LIST");employeeRegisterDetail(doc.employeeid)};cellAction.appendChild(btEmp)}}
if(response.length>=FILTER.pageItems){let newRowC=tableRef.insertRow(-1);newRowC.id="rowEmpDocStaRowAddMore";newRowC.setAttribute("class","noPrint borderGray font-size-x-large text-align-center");newRowC.style.cursor="pointer";let cellDescription=newRowC.insertCell(-1);cellDescription.innerHTML="<b>VER MAIS...</b>";cellDescription.setAttribute("colspan","7");newRowC.onclick=function(){employeeDocumentStatusList(employeeId,FILTER.startIdx+FILTER.pageItems)}}
hideNotification()}
result()}};http.send(params)}
function employeeDocumentStatusRegisterNew(doc){if(!isNaN(Number(doc.contractid))){setElementInnerHtml("h2EmpDocRegHeader","Detalhes do documento")}else{setElementInnerHtml("h2EmpDocRegHeader","Novo documento")}
showParts("divEmployeeDocumentRegister");setElementInnerHtml("lbEmpDocRegDocumentId",doc.documentid);setElementInnerHtml("lbEmpDocRegEmployeeId",doc.employeeid);setElementInnerHtml("txtEmpDocRegEmployeeName",doc.employeename);setElementValue("selEmpDocRegIdentificationDoc",doc.identificationdocument);setElementValue("txtEmpDocRegDocType",doc.documenttype);setElementValue("txtEmpDocRegDocNumber",doc.documentnnumber);setElementValue("txtEmpDocRegEmissionDate",setLocalDate(doc.emissiondate,10));setElementValue("txtEmpDocRegExpiryDate",setLocalDate(doc.expirydate,10));setElementInnerHtml("lbEmpDocRegPhotoOld",doc.photo);setElementInnerHtml("aEmpDocRegPhoto",doc.photo);setElementAttribute("aEmpDocRegPhoto","href",doc.photopath);setElementInnerHtml("lbEmpDocRegUpdate","Cadastrado por "+getOperatorName(doc.operatorEntry,doc.entryuser)+" em "+setLocalDate(doc.entrydate,16)+". <br>"+"Actualizado por "+getOperatorName(doc.operatorName,doc.statususer)+" em "+setLocalDate(doc.statusdate,16));let ifr=document.getElementById("iframeEmpDocRegUploadAttach");ifr.src+="&a"+randomString(3)+"="+randomString(3);dispatchOnInputChange();setAutoCompleteToFiel("txtEmpDocRegDocType",53);setAutoCompleteToFiel("txtEmpDocRegDocNumber",54)}
function employeeDocumentStatusRegisterOnLoad(){window.addEventListener('message',employeeDocumentRegisterReceiveMessage,!1)}
function employeeDocumentRegisterReceiveMessage(event){var response=event.data;if(response.status==1){showNotification(response.msg,1);if(response.wc=="EMPDOCSTAREG"){setElementInnerHtml("aEmpDocRegPhoto",response.tempfile);var aPhoto=document.getElementById("aEmpDocRegPhoto");aPhoto.href=URL_SRH_TEMP_FILE_X+response.tempfile}}else{showNotification(response.msg,0)}}
function employeeDocumentStatusSave(){if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();FILTER.documentid=getElementInnerHTML("lbEmpDocRegDocumentId");FILTER.employeeid=getElementInnerHTML("lbEmpDocRegEmployeeId");FILTER.identificationdocument=getElementValue("selEmpDocRegIdentificationDoc");FILTER.documenttype=reviewString(document.getElementById("txtEmpDocRegDocType")).toUpperCase();FILTER.documentnnumber=reviewString(document.getElementById("txtEmpDocRegDocNumber")).toUpperCase();FILTER.emissiondate=getElementValue("txtEmpDocRegEmissionDate");FILTER.expirydate=getElementValue("txtEmpDocRegExpiryDate");FILTER.photoOld=getElementInnerHTML("lbEmpDocRegPhotoOld");FILTER.photo=getElementInnerHTML("aEmpDocRegPhoto");var mandatoryField=!1;var msg="";if(FILTER.employeeid==""){mandatoryField=!0;msg+="Deve indicar o trabalhador. <br>"}
if((FILTER.documenttype=="")||(FILTER.documentnnumber=="")){mandatoryField=!0;msg+="Deve indicar o tipo de documeto / nº do documento. <br>"}
if(new Date(FILTER.emissiondate).getTime()>=new Date(FILTER.expirydate).getTime()){mandatoryField=!0;msg+="A data de emissão de ser sempre inferior a data de caducidade. <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=saveEmployeeDocumentStatus"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_EMPLOYEE_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("divEmployeeDocumentRegister");if(ST_SRH_MAIN_WHO_CALL=="EMPDOCSTALIST"){employeeDocumentStatusList(result.employeeid)}
setElementInnerHtml("lbEmpDocRegEmployeeId")}else{showNotification(result.msg,0)}}};http.send(params)}
function employeeDocumentStatusDelete(doc){function realDelete(){if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();FILTER.documentid=doc.documentid;FILTER.photo=doc.photo;showNotification();var http=new XMLHttpRequest();var params="action=deleteEmployeeDocumentStatus"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_EMPLOYEE_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 result=validateSession(http);if(result.status==!0){showNotification(result.msg,1);if(ST_SRH_MAIN_WHO_CALL=="EMPDOCSTALIST"){employeeDocumentStatusList()}}else{showNotification(result.msg,0)}}};http.send(params)}
showConfirm("Tem a certeza que deseja apagar este documento?",realDelete)}
var EMPLOYEE_CURRENT_CATEGORY_NEW_ASSIGN=0;function employeeAssignCategoryListOnLoad(){showNotification();setPageTitleWhoCall("4001-4002-4003","EMPCURCATLIST","Aplicar categoria / função");function cdoLoad(){fillSelectSex("selEmpAssCatListSex",-1);fillSelectCountry("selEmpAssCatListCountry",-1);fillSelectDepartment("selEmpAssCatListDepartment",-1);fillSelectEmployeeCategory("selEmpAssCatListEmployeeCategory",-1);fillSelectEmployeeCategory("selEmpContrRegCategoryID",-1);var date=new Date();setElementValue("txtEmpAssCatListInitialDate",setLocalDate(new Date(date.getFullYear(),0,1),10));setElementValue("txtEmpAssCatListEndDate",setLocalDate(new Date(),10));setTriggerButtonByText('txtEmpAssCatListInitialDate','btEmpAssCatListViewAll');setTriggerButtonByText('txtEmpAssCatListEndDate','btEmpAssCatListViewAll');if(!checkPermission("4002")){removeElement("btEmpLisNewEmployee");removeElement("divEmployeeRegister");removeElement("btEmpAssCatListCurrentCategoryNew");removeElement("divEmployeeCurrentCategoryRegister")}
if(!checkPermission("4111")){removeElement("btEmpWorSchRegWorkscheduleNew");removeElement("divWorkscheduleRegister")}
EMPLOYEE_CURRENT_CATEGORY_NEW_ASSIGN=0;employeeSearchOnLoad();employeeRegisterOnLoad();hideNotification()}
checkUserStatusAfterExecute(cdoLoad)}
function employeeAssignCategoryList(employeeId=-1,startIdx=0){if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();FILTER.employeeId=employeeId;FILTER.filterByDate=getElementChecked("chbEmpAssCatListShowDate");FILTER.initialDate=getElementValue('txtEmpAssCatListInitialDate');FILTER.endDate=getElementValue('txtEmpAssCatListEndDate');FILTER.sex=getElementValue("selEmpAssCatListSex");FILTER.nationality=getElementValue("selEmpAssCatListCountry");FILTER.departmentId=getElementValue("selEmpAssCatListDepartment");FILTER.categoryId=getElementValue("selEmpAssCatListEmployeeCategory");FILTER.startIdx=startIdx;if(ST_SRH_WAITING_SERVER==1){showNotification("Aguardando resposta do servidor. <br>",0);return!1}
let tableRef=document.getElementById("tblEmpAssCatListMainTable");if(FILTER.startIdx==0){tableRef.innerHTML=""}else{removeElement("rowEmpAssCatAddMore")}
showNotification();ST_SRH_WAITING_SERVER=1;var http=new XMLHttpRequest();var params="action=getEnployeeAssignCategoryList"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_EMPLOYEE_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 response=validateSession(http);var totalItems=response.length;if(totalItems>0){hideDivFilter()}
function result(){tableRef.innerHTML+=strFilterResult(response);setElementInnerHtml('lbResultOnList',FILTER.startIdx+response.length);var nRows=startIdx;for(var i=0;i<response.length;i++){let category=JSON.parse(response[i]);nRows+=1;let newRow=tableRef.insertRow(-1);newRow.setAttribute("id","rowEmpAssCatListRow"+category.currentcategoryid);newRow.setAttribute("class","borderGray"+setSelectedRowBackground("SELECTED_ROW_EMPLOYEE_ASSIGN_CATEGORY_LIST",newRow.id));let cellRow=createTableCell(newRow,nRows,"colRowNumber","#");let cellId=createTableCell(newRow,category.employeeid,"colProductId","Código");let cellAgent=createTableCell(newRow,leadingZero(category.agentnumberreal,4),"colProductId","Nº de agente");let cellName=createTableCell(newRow,category.employeename,"col-width-110","Nome completo");let cellCategory=createTableCell(newRow,category.category,"","Categoria / função");let cellDate=createTableCell(newRow,setLocalDate(category.startdate,10),"text-align-center colNoWrap ","Início de função");let cellCatTime=createTableCell(newRow,category.categorytime,"colProductId","Tempo na função");let cellUpdate=createTableCell(newRow,setLocalDate(category.statusdate,16),"colProductId","Última actualização");let cellOper=createTableCell(newRow,getFirtLastName(category.operatorName)+" ("+category.statususer+")","colProductId","Operador");let cellAction=createTableCell(newRow,"","noPrint text-align-center","...");if(checkPermission("4002")){let btEdit=createElement("button","button","labelEdit");btEdit.onclick=function(){setSelectedRowOnClick(newRow,"SELECTED_ROW_EMPLOYEE_ASSIGN_CATEGORY_LIST");employeeAssignCategoryRegisterNew(category)};cellAction.appendChild(btEdit);let btDelete=createElement("button","button","labelDelete");btDelete.onclick=function(){setSelectedRowOnClick(newRow,"SELECTED_ROW_EMPLOYEE_ASSIGN_CATEGORY_LIST");employeeAssignCategoryDelete(category)};cellAction.appendChild(btDelete);let btEmp=createElement("button","button","labelCustomer");btEmp.innerHTML="Trabalhador";btEmp.onclick=function(){setSelectedRowOnClick(newRow,"SELECTED_ROW_EMPLOYEE_ASSIGN_CATEGORY_LIST");employeeRegisterDetail(category.employeeid)};cellAction.appendChild(btEmp)}}
if(response.length>=FILTER.pageItems){let newRowC=tableRef.insertRow(-1);newRowC.id="rowEmpAssCatAddMore";newRowC.setAttribute("class","noPrint borderGray font-size-x-large text-align-center");newRowC.style.cursor="pointer";let cellDescription=newRowC.insertCell(-1);cellDescription.innerHTML="<b>VER MAIS...</b>";cellDescription.setAttribute("colspan","7");newRowC.onclick=function(){employeeAssignCategoryList(employeeId,FILTER.startIdx+FILTER.pageItems)}}
hideNotification()}
result()}};http.send(params)}
function employeeAssignCategoryRegisterNew(category){if(!isNaN(Number(category.currentcategoryid))){setElementInnerHtml("h2EmpAssCatRegHeader","Dados da aplicação")}else{setElementInnerHtml("h2EmpAssCatRegHeader","Nova aplicação")}
showParts("divEmployeeCurrentCategoryRegister");setElementInnerHtml("lbEmpAssCatRegCurrentCategoryId",category.currentcategoryid);setElementInnerHtml("lbEmpAssCatRegEmployeeId",category.employeeid);setElementInnerHtml("txtEmpAssCatRegEmployeeName",category.employeename);setElementValue("txtEmpAssCatRegPreviousCategory",category.previuoscategory);fillSelectEmployeeCategory("selEmpAssCatRegCategoryId",-1,category.categoryid);setElementValue("txtEmpAssCatRegStartDate",setLocalDate(category.startdate,10));setElementValue("txtEmpAssCatRegDispatchNumber",category.dispatchnumber);setElementInnerHtml("lbEmpAssCatRegPhotoOld",category.photo);setElementInnerHtml("aEmpAssCatRegPhoto",category.photo);setElementAttribute("aEmpAssCatRegPhoto","href",category.photopath);setElementInnerHtml("lbEmpAssCatRegUpdate","Cadastrado por "+getOperatorName(category.operatorEntry,category.entryuser)+" em "+setLocalDate(category.entrydate,16)+". <br>"+"Actualizado por "+getOperatorName(category.operatorName,category.statususer)+" em "+setLocalDate(category.statusdate,16));dispatchOnInputChange();var ifr=document.getElementById("iframeEmpAssCatRegUploadAttach");ifr.src+="&a"+randomString(3)+"="+randomString(3)}
function employeeAssignCategorySave(){if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();FILTER.currentcategoryid=getElementInnerHTML("lbEmpAssCatRegCurrentCategoryId");FILTER.employeeid=getElementInnerHTML("lbEmpAssCatRegEmployeeId");FILTER.previuoscategory=reviewString(document.getElementById("txtEmpAssCatRegPreviousCategory")).toUpperCase();FILTER.categoryid=getElementValue("selEmpAssCatRegCategoryId");FILTER.startdate=getElementValue("txtEmpAssCatRegStartDate");FILTER.dispatchnumber=reviewString(document.getElementById("txtEmpAssCatRegDispatchNumber")).toUpperCase();FILTER.photoOld=getElementInnerHTML("lbEmpAssCatRegPhotoOld");FILTER.photo=getElementInnerHTML("aEmpAssCatRegPhoto");var mandatoryField=!1;var msg="";if(FILTER.employeeid==""){mandatoryField=!0;msg+="Deve indicar o trabalhador. <br>"}
if(Number(FILTER.categoryid)<=0){mandatoryField=!0;msg+="Deve indicar a função. <br>"}
if(window.location.hostname.toString().includes("sepasza")){if(FILTER.previuoscategory==""){mandatoryField=!0;msg+="Deve indicar a cateforia. <br>"}
if(FILTER.dispatchnumber==""){mandatoryField=!0;msg+="Deve indicar o número de despacho. <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=saveEmployeeAssignCategory"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_EMPLOYEE_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("divEmployeeCurrentCategoryRegister");employeeAssignCategoryList(result.employeeid);setElementInnerHtml("lbEmpAssCatRegEmployeeId")}else{showNotification(result.msg,0)}}};http.send(params)}
function employeeAssignCategoryDelete(category){function realDelete(){if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();FILTER.currentcategoryid=category.currentcategoryid;showNotification();var http=new XMLHttpRequest();var params="action=deleteEmployeeAssignCategory"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_EMPLOYEE_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 result=validateSession(http);if(result.status==!0){showNotification(result.msg,1);employeeAssignCategoryList()}else{showNotification(result.msg,0)}}};http.send(params)}
showConfirm("Tem a certeza que deseja apagar esta categoria?",realDelete)}
var EMPLOYEE_DEPARTMENT_NEW_ASSIGN=0;function employeeDepartmentListOnLoad(){showNotification();setPageTitleWhoCall("4001-4002-4003","EMPDEPLIST","Indicar posto de trabalho");function cdoLoad(){fillSelectDependencyFull("selEmpDepListDependency",-1,1);fillSelectSex("selEmpDepListSex",-1);fillSelectCountry("selEmpDepListCountry",-1);fillSelectDepartment("selEmpDepListDepartment",-1);fillSelectEmployeeCategory("selEmpDepListEmployeeCategory",-1);fillSelectEmployeeCategory("selEmpContrRegCategoryID",-1);var date=new Date();setElementValue("txtEmpDepListInitialDate",setLocalDate(new Date(date.getFullYear(),0,1),10));setElementValue("txtEmpDepListEndDate",setLocalDate(new Date(),10));setTriggerButtonByText('txtEmpDepListInitialDate','btEmpDepListViewAll');setTriggerButtonByText('txtEmpDepListEndDate','btEmpDepListViewAll');if(!checkPermission("4002")){removeElement("btEmpLisNewEmployee");removeElement("divEmployeeRegister");removeElement("btEmpDepListDepartmentNew");removeElement("divEmployeeDepartmentRegister")}
if(!checkPermission("4111")){removeElement("btEmpWorSchRegWorkscheduleNew");removeElement("divWorkscheduleRegister")}
EMPLOYEE_DEPARTMENT_NEW_ASSIGN=0;employeeSearchOnLoad();employeeRegisterOnLoad();hideNotification()}
checkUserStatusAfterExecute(cdoLoad)}
function employeeDepartmentList(employeeId=-1,startIdx=0){if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();FILTER.dependencyId=getElementValue("selEmpDepListDependency");FILTER.employeeId=employeeId;FILTER.filterByDate=getElementChecked("chbEmpDepListShowDate");FILTER.initialDate=getElementValue('txtEmpDepListInitialDate');FILTER.endDate=getElementValue('txtEmpDepListEndDate');FILTER.sex=getElementValue("selEmpDepListSex");FILTER.nationality=getElementValue("selEmpDepListCountry");FILTER.departmentId=getElementValue("selEmpDepListDepartment");FILTER.categoryId=getElementValue("selEmpDepListEmployeeCategory");FILTER.startIdx=startIdx;if(ST_SRH_WAITING_SERVER==1){showNotification("Aguardando resposta do servidor. <br>",0);return!1}
let tableRef=document.getElementById("tblEmpDepListMainTable");if(FILTER.startIdx==0){tableRef.innerHTML=""}else{removeElement("rowEmpDepartListRowAddMore")}
showNotification();ST_SRH_WAITING_SERVER=1;var http=new XMLHttpRequest();var params="action=getEnployeeDepartmentList"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_EMPLOYEE_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 response=validateSession(http);var totalItems=response.length;if(totalItems>0){hideDivFilter()}
setElementInnerHtml('lbResultOnList',FILTER.startIdx+response.length);function result(){tableRef.innerHTML+=strFilterResult(response);var nRows=startIdx;for(var i=0;i<response.length;i++){let department=JSON.parse(response[i]);nRows+=1;let newRow=tableRef.insertRow(-1);newRow.setAttribute("id","rowEmpDepartListRow"+department.workplaceid);newRow.setAttribute("class","borderGray"+setSelectedRowBackground("SELECTED_ROW_EMPLOYEE_DEPARTMENT_LIST",newRow.id));let cellRow=createTableCell(newRow,nRows,"colRowNumber","#");let cellId=createTableCell(newRow,department.employeeid,"colProductId","Código");let cellAgent=createTableCell(newRow,leadingZero(department.agentnumberreal,4),"colProductId","Nº de agente");let cellName=createTableCell(newRow,department.employeename,"col-width-110","Nome completo");let cellDepart=createTableCell(newRow,department.department,"","Posto de trabalho");let cellDate=createTableCell(newRow,setLocalDate(department.startdate,10),"text-align-center colNoWrap ","Data de indicação");let cellUpdate=createTableCell(newRow,setLocalDate(department.statusdate,16),"colProductId","Última actualização");let cellOper=createTableCell(newRow,getFirtLastName(department.operatorName)+" ("+department.statususer+")","colProductId","Operador");let cellAction=createTableCell(newRow,"","noPrint text-align-center","...");if(checkPermission("4002")){let btEdit=createElement("button","button","labelEdit");btEdit.onclick=function(){setSelectedRowOnClick(newRow,"SELECTED_ROW_EMPLOYEE_DEPARTMENT_LIST");employeeDepartmentRegisterNew(department)};cellAction.appendChild(btEdit);let btDelete=createElement("button","button","labelDelete");btDelete.onclick=function(){setSelectedRowOnClick(newRow,"SELECTED_ROW_EMPLOYEE_DEPARTMENT_LIST");employeeDepartmentDelete(department)};cellAction.appendChild(btDelete);let btEmp=createElement("button","button","labelCustomer");btEmp.innerHTML="Trabalhador";btEmp.onclick=function(){setSelectedRowOnClick(newRow,"SELECTED_ROW_EMPLOYEE_DEPARTMENT_LIST");employeeRegisterDetail(department.employeeid)};cellAction.appendChild(btEmp)}}
if(response.length>=FILTER.pageItems){let newRowC=tableRef.insertRow(-1);newRowC.id="rowEmpDepartListRowAddMore";newRowC.setAttribute("class","noPrint borderGray font-size-x-large text-align-center");newRowC.style.cursor="pointer";let cellDescription=newRowC.insertCell(-1);cellDescription.innerHTML="<b>VER MAIS...</b>";cellDescription.setAttribute("colspan","7");newRowC.onclick=function(){employeeDepartmentList(employeeId,FILTER.startIdx+FILTER.pageItems)}}
hideNotification()}
result()}};http.send(params)}
function employeeDepartmentRegisterNew(department){if(!isNaN(Number(department.workplaceid))){setElementInnerHtml("h2EmpDepartRegHeader","Dados da aplicação")}else{setElementInnerHtml("h2EmpDepartRegHeader","Nova indicação")}
showParts("divEmployeeDepartmentRegister");setElementInnerHtml("lbEmpDepartRegWorkplaceId",department.workplaceid);setElementInnerHtml("lbEmpDepartRegEmployeeId",department.employeeid);setElementInnerHtml("txtEmpDepartRegEmployeeName",department.employeename);fillSelectDepartment("selEmpDepartRegDepartmentId",-1,department.departmetid);setElementValue("txtEmpDepartRegStartDate",setLocalDate(department.startdate,10));setElementValue("txtEmpDepartRegDispatchNumber",department.dispatchnumber);setElementInnerHtml("lbEmpDepartRegPhotoOld",department.photo);setElementInnerHtml("aEmpDepartRegPhoto",department.photo);setElementAttribute("aEmpDepartRegPhoto","href",department.photopath);setElementInnerHtml("lbEmpDepartRegUpdate","Cadastrado por "+getOperatorName(department.operatorEntry,department.entryuser)+" em "+setLocalDate(department.entrydate,16)+". <br>"+"Actualizado por "+getOperatorName(department.operatorName,department.statususer)+" em "+setLocalDate(department.statusdate,16));dispatchOnInputChange();let ifr=document.getElementById("iframeEmpDepartRegUploadAttach");ifr.src+="&a"+randomString(3)+"="+randomString(3)}
function employeeDepartmentSave(){if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();FILTER.workplaceid=getElementInnerHTML("lbEmpDepartRegWorkplaceId");FILTER.employeeid=getElementInnerHTML("lbEmpDepartRegEmployeeId");FILTER.departmetid=getElementValue("selEmpDepartRegDepartmentId");FILTER.startdate=getElementValue("txtEmpDepartRegStartDate");FILTER.dispatchnumber=reviewString(document.getElementById("txtEmpDepartRegDispatchNumber"));FILTER.photoOld=getElementInnerHTML("lbEmpDepartRegPhotoOld");FILTER.photo=getElementInnerHTML("aEmpDepartRegPhoto");var mandatoryField=!1;var msg="";if(FILTER.employeeid==""){mandatoryField=!0;msg+="Deve indicar o trabalhador. <br>"}
if(Number(FILTER.departmetid)<=0){mandatoryField=!0;msg+="Deve indicar o posto de trabalho. <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=saveEmployeeDepartment"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_EMPLOYEE_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("divEmployeeDepartmentRegister");employeeDepartmentList(result.employeeid);setElementInnerHtml("lbEmpDepartRegEmployeeId")}else{showNotification(result.msg,0)}}};http.send(params)}
function employeeDepartmentDelete(department){function realDelete(){if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();FILTER.workplaceid=department.workplaceid;showNotification();var http=new XMLHttpRequest();var params="action=deleteEmployeeDepartment"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_EMPLOYEE_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 result=validateSession(http);if(result.status==!0){showNotification(result.msg,1);employeeDepartmentList()}else{showNotification(result.msg,0)}}};http.send(params)}
showConfirm("Tem a certeza que deseja apagar este posto de trabalho?",realDelete)}
function employeeBiographicDataListOnLoad(){showNotification();setPageTitleWhoCall("4001-4002-4003","EMPBIODATALIST","Lista com dados biográficos");function cdoLoad(){fillSelectDependencyFull("selEmpBioDataListDependency",-1,1);fillSelectSex("selEmpBioDataListSex",-1);fillSelectCountry("selEmpBioDataListCountry",-1);fillSelectDepartment("selEmpBioDataListDepartment",-1);fillSelectEmployeeCategory("selEmpBioDataListEmployeeCategory",-1);fillSelectEmployeeCategory("selEmpContrRegCategoryID",-1);var date=new Date();setElementValue("txtEmpBioDataListInitialDate",setLocalDate(new Date(date.getFullYear(),0,1),10));setElementValue("txtEmpBioDataListEndDate",setLocalDate(new Date(),10));setTriggerButtonByText('txtEmpBioDataListInitialDate','btEmpBioDataListViewAll');setTriggerButtonByText('txtEmpBioDataListEndDate','btEmpBioDataListViewAll');employeeSearchOnLoad();employeeRegisterOnLoad();hideNotification()}
checkUserStatusAfterExecute(cdoLoad)}
function employeeBiographicDataList(employeeId=-1,startIdx=0){if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();FILTER.dependencyId=getElementValue("selEmpBioDataListDependency");FILTER.employeeId=employeeId;FILTER.filterByDate=getElementChecked("chbEmpBioDataListShowDate");FILTER.initialDate=getElementValue('txtEmpBioDataListInitialDate');FILTER.endDate=getElementValue('txtEmpBioDataListEndDate');FILTER.sex=getElementValue("selEmpBioDataListSex");FILTER.nationality=getElementValue("selEmpBioDataListCountry");FILTER.departmentId=getElementValue("selEmpBioDataListDepartment");FILTER.categoryId=getElementValue("selEmpBioDataListEmployeeCategory");FILTER.startIdx=startIdx;if(ST_SRH_WAITING_SERVER==1){showNotification("Aguardando resposta do servidor. <br>",0);return!1}
let tableRef=document.getElementById("tblEmpBioDataListMainTable");if(FILTER.startIdx==0){tableRef.innerHTML=""}else{removeElement("rowEmpBiDataRowAddMore")}
showNotification();ST_SRH_WAITING_SERVER=1;var http=new XMLHttpRequest();var params="action=getEmployeeList"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_EMPLOYEE_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 response=validateSession(http);var totalItems=response.length;if(totalItems>0){hideDivFilter()}
setElementInnerHtml('lbResultOnList',FILTER.startIdx+response.length);function result(){tableRef.innerHTML+=strFilterResult(response);var nRows=startIdx;for(var i=0;i<response.length;i++){let employee=JSON.parse(response[i]);nRows+=1;let newRow=tableRef.insertRow(-1);newRow.setAttribute("id","rowEmpDepartListRow"+employee.employeeid);newRow.setAttribute("class","borderGray"+setSelectedRowBackground("SELECTED_ROW_EMPLOYEE_DEPARTMENT_LIST",newRow.id));let cellRow=createTableCell(newRow,nRows,"colRowNumber","#");let cellId=createTableCell(newRow,employee.employeeid,"colProductId","Código");let cellAgent=createTableCell(newRow,leadingZero(employee.agentnumberreal,4),"colProductId","Código");let cellName=createTableCell(newRow,employee.employeename,"col-width-150 headcol","Nome completo");let cellAge=createTableCell(newRow,Math.round(employee.age),"text-align-center","Idade");let cellDate=createTableCell(newRow,setLocalDate(employee.birthdate,10),"text-align-center colNoWrap ","Data de nascimento");let cellNati=createTableCell(newRow,employee.countryName,"font-size-small","Nacionalidade");let cellBCount=createTableCell(newRow,employee.birthcountryName,"font-size-small","País de nascimento");let cellBPlace=createTableCell(newRow,employee.birthplace,"font-size-small","Local de nascimento");let cellFather=createTableCell(newRow,employee.fathername,"font-size-small","Pai");let cellMother=createTableCell(newRow,employee.mothername,"font-size-small","Mãe");let cellSex=createTableCell(newRow,employee.sex,"text-align-center font-size-small","Sexo");let cellMStatus=createTableCell(newRow,employee.maritalstatus,"text-align-center font-size-small","Estado civil");let cellUpdate=createTableCell(newRow,setLocalDate(employee.statusdate,16),"colProductId","Última actualização");let cellOper=createTableCell(newRow,getFirtLastName(employee.operatorName)+" ("+employee.statususer+")","colProductId","Operador");let cellAction=createTableCell(newRow,"","noPrint text-align-center","...");if(checkPermission("4002")){let btEmp=createElement("button","button","labelCustomer");btEmp.innerHTML="Trabalhador";btEmp.onclick=function(){setSelectedRowOnClick(newRow,"SELECTED_ROW_EMPLOYEE_DEPARTMENT_LIST");employeeRegisterDetail(employee.employeeid)};cellAction.appendChild(btEmp)}}
if(response.length>=FILTER.pageItems){let newRowC=tableRef.insertRow(-1);newRowC.id="rowEmpBiDataRowAddMore";newRowC.setAttribute("class","noPrint borderGray font-size-x-large text-align-center");newRowC.style.cursor="pointer";let cellDescription=newRowC.insertCell(-1);cellDescription.innerHTML="<b>VER MAIS...</b>";cellDescription.setAttribute("colspan","7");newRowC.onclick=function(){employeeBiographicDataList(employeeId,FILTER.startIdx+FILTER.pageItems)}}
hideNotification()}
result()}};http.send(params)}
function employeeContactListOnLoad(){showNotification();setPageTitleWhoCall("4001-4002-4003","EMPCONTLIST","Lista com contactos e endereços");function cdoLoad(){fillSelectDependencyFull("selEmpContListDependency",-1,1);fillSelectSex("selEmpContListSex",-1);fillSelectCountry("selEmpContListCountry",-1);fillSelectDepartment("selEmpContListDepartment",-1);fillSelectEmployeeCategory("selEmpContListEmployeeCategory",-1);fillSelectEmployeeCategory("selEmpContrRegCategoryID",-1);var date=new Date();setElementValue("txtEmpContListInitialDate",setLocalDate(new Date(date.getFullYear(),0,1),10));setElementValue("txtEmpContListEndDate",setLocalDate(new Date(),10));setTriggerButtonByText('txtEmpContListInitialDate','btEmpContListViewAll');setTriggerButtonByText('txtEmpContListEndDate','btEmpContListViewAll');employeeSearchOnLoad();employeeRegisterOnLoad();hideNotification()}
checkUserStatusAfterExecute(cdoLoad)}
function employeeContactList(employeeId=-1,startIdx=0){if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();FILTER.dependencyId=getElementValue("selEmpContListDependency");FILTER.employeeId=employeeId;FILTER.filterByDate=getElementChecked("chbEmpContListShowDate");FILTER.initialDate=getElementValue('txtEmpContListInitialDate');FILTER.endDate=getElementValue('txtEmpContListEndDate');FILTER.sex=getElementValue("selEmpContListSex");FILTER.nationality=getElementValue("selEmpContListCountry");FILTER.departmentId=getElementValue("selEmpContListDepartment");FILTER.categoryId=getElementValue("selEmpContListEmployeeCategory");FILTER.startIdx=startIdx;if(ST_SRH_WAITING_SERVER==1){showNotification("Aguardando resposta do servidor. <br>",0);return!1}
let tableRef=document.getElementById("tblEmpContListMainTable");if(FILTER.startIdx==0){tableRef.innerHTML=""}else{removeElement("rowEmpContListRowAddMore")}
showNotification();ST_SRH_WAITING_SERVER=1;var http=new XMLHttpRequest();var params="action=getEmployeeList"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_EMPLOYEE_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 response=validateSession(http);var totalItems=response.length;if(totalItems>0){hideDivFilter()}
setElementInnerHtml('lbResultOnList',FILTER.startIdx+response.length);function result(){tableRef.innerHTML+=strFilterResult(response);var nRows=startIdx;for(var i=0;i<response.length;i++){let employee=JSON.parse(response[i]);nRows+=1;let newRow=tableRef.insertRow(-1);newRow.setAttribute("id","rowEmpDepartListRow"+employee.workplaceid);newRow.setAttribute("class","borderGray"+setSelectedRowBackground("SELECTED_ROW_EMPLOYEE_DEPARTMENT_LIST",newRow.id));let cellRow=createTableCell(newRow,nRows,"colRowNumber","#");let cellId=createTableCell(newRow,employee.employeeid,"colProductId","Código");let cellAgent=createTableCell(newRow,leadingZero(employee.agentnumberreal,4),"colProductId","Código");let cellName=createTableCell(newRow,employee.employeename,"col-width-150 headcol","Nome completo");let cellAddr=createTableCell(newRow,employee.addresscurrent,"font-size-small","Endereço");let cellAddress=createTableCell(newRow,employee.addressalternative,"font-size-small","Endereço alternativo");let cellPhone=createTableCell(newRow,employee.phone1,"font-size-small","Telefone");let cellPhone2=createTableCell(newRow,employee.phone2,"font-size-small","Telefone");let cellPhone3=createTableCell(newRow,employee.phone3,"font-size-small","Telefone");let cellEmail=createTableCell(newRow,employee.email,"text-align-center font-size-small","Email");let cellUpdate=createTableCell(newRow,setLocalDate(employee.statusdate,16),"colProductId","Última actualização");let cellOper=createTableCell(newRow,getFirtLastName(employee.operatorName)+" ("+employee.statususer+")","colProductId","Operador");let cellAction=createTableCell(newRow,"","noPrint text-align-center","...");if(checkPermission("4002")){let btEmp=createElement("button","button","labelCustomer");btEmp.innerHTML="Trabalhador";btEmp.onclick=function(){setSelectedRowOnClick(newRow,"SELECTED_ROW_EMPLOYEE_DEPARTMENT_LIST");employeeRegisterDetail(employee.employeeid)};cellAction.appendChild(btEmp)}}
if(response.length>=FILTER.pageItems){let newRowC=tableRef.insertRow(-1);newRowC.id="rowEmpContListRowAddMore";newRowC.setAttribute("class","noPrint borderGray font-size-x-large text-align-center");newRowC.style.cursor="pointer";let cellDescription=newRowC.insertCell(-1);cellDescription.innerHTML="<b>VER MAIS...</b>";cellDescription.setAttribute("colspan","7");newRowC.onclick=function(){employeeContactList(employeeId,FILTER.startIdx+FILTER.pageItems)}}
hideNotification()}
result()}};http.send(params)}
var EMPLOYEE_BANK_NEW_ASSIGN=0;function employeeBankListOnLoad(){showNotification();setPageTitleWhoCall("4001-4002-4003","EMPBANKLIST","Indicar coordenadas bancárias");function cdoLoad(){fillSelectDependencyFull("selEmpBankListDependency",-1,1);fillSelectNationalBank("selEmpBankListBank",-1);fillSelectCountry("selEmpBankListCountry",-1);fillSelectDepartment("selEmpBankListDepartment",-1);fillSelectEmployeeCategory("selEmpBankListEmployeeCategory",-1);fillSelectEmployeeCategory("selEmpContrRegCategoryID",-1);var date=new Date();setElementValue("txtEmpBankListInitialDate",setLocalDate(new Date(date.getFullYear(),0,1),10));setElementValue("txtEmpBankListEndDate",setLocalDate(new Date(),10));setTriggerButtonByText('txtEmpBankListInitialDate','btEmpBankListViewAll');setTriggerButtonByText('txtEmpBankListEndDate','btEmpBankListViewAll');if(!checkPermission("4002")){removeElement("btEmpLisNewEmployee");removeElement("divEmployeeRegister");removeElement("btEmpBankListBankNew");removeElement("divEmployeeBankRegister")}
if(!checkPermission("4111")){removeElement("btEmpWorSchRegWorkscheduleNew");removeElement("divWorkscheduleRegister")}
EMPLOYEE_BANK_NEW_ASSIGN=0;employeeSearchOnLoad();employeeRegisterOnLoad();employeeBankRgeisterOnLoad();hideNotification()}
checkUserStatusAfterExecute(cdoLoad)}
function employeeBankList(employeeId=-1,startIdx=0){if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();FILTER.dependencyId=getElementValue("selEmpBankListDependency");FILTER.employeeId=employeeId;FILTER.filterByDate=getElementChecked("chbEmpBankListShowDate");FILTER.initialDate=getElementValue('txtEmpBankListInitialDate');FILTER.endDate=getElementValue('txtEmpBankListEndDate');FILTER.bank=getElementValue("selEmpBankListBank");FILTER.nationality=getElementValue("selEmpBankListCountry");FILTER.departmentId=getElementValue("selEmpBankListDepartment");FILTER.categoryId=getElementValue("selEmpBankListEmployeeCategory");FILTER.startIdx=startIdx;if(ST_SRH_WAITING_SERVER==1){showNotification("Aguardando resposta do servidor. <br>",0);return!1}
let tableRef=document.getElementById("tblEmpBankListMainTable");if(FILTER.startIdx==0){tableRef.innerHTML=""}else{removeElement("rowEmpBankRowAddMore")}
showNotification();ST_SRH_WAITING_SERVER=1;var http=new XMLHttpRequest();var params="action=getEnployeeBankList"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_EMPLOYEE_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 response=validateSession(http);var totalItems=response.length;if(totalItems>0){hideDivFilter()}
function result(){tableRef.innerHTML+=strFilterResult(response);setElementInnerHtml('lbResultOnList',FILTER.startIdx+response.length);var nRows=startIdx;for(var i=0;i<response.length;i++){let account=JSON.parse(response[i]);nRows+=1;let newRow=tableRef.insertRow(-1);newRow.setAttribute("id","rowEmpBankListRow"+account.accountid);newRow.setAttribute("class","borderGray"+setSelectedRowBackground("SELECTED_ROW_EMPLOYEE_BANK_LIST",newRow.id));let cellRow=createTableCell(newRow,nRows,"colRowNumber","#");let cellId=createTableCell(newRow,account.employeeid,"colProductId","Código");let cellAgent=createTableCell(newRow,leadingZero(account.agentnumberreal,4),"colProductId","Nº de agente");let cellName=createTableCell(newRow,account.employeename,"col-width-110 headcol","Nome completo");let cellBank=createTableCell(newRow,account.bank,"text-align-center","Banco");let cellAcc=createTableCell(newRow,account.accountnumber,"","Conta");let cellIban=createTableCell(newRow,account.iban,"","IBAN");let cellDate=createTableCell(newRow,setLocalDate(account.startdate,10),"text-align-center colNoWrap ","Início do contrato");let cellUpdate=createTableCell(newRow,setLocalDate(account.statusdate,16),"colProductId","Última actualização");let cellOper=createTableCell(newRow,getFirtLastName(account.operatorName)+" ("+account.statususer+")","colProductId","Operador");let cellAction=createTableCell(newRow,"","noPrint text-align-center","...");if(checkPermission("4002")){let btEdit=createElement("button","button","labelEdit");btEdit.onclick=function(){setSelectedRowOnClick(newRow,"SELECTED_ROW_EMPLOYEE_BANK_LIST");employeeBankRegisterNew(account)};cellAction.appendChild(btEdit);let btDelete=createElement("button","button","labelDelete");btDelete.onclick=function(){setSelectedRowOnClick(newRow,"SELECTED_ROW_EMPLOYEE_BANK_LIST");employeeBankDelete(account)};cellAction.appendChild(btDelete);let btEmp=createElement("button","button","labelCustomer");btEmp.innerHTML="Trabalhador";btEmp.onclick=function(){setSelectedRowOnClick(newRow,"SELECTED_ROW_EMPLOYEE_ASSIGN_CATEGORY_LIST");employeeRegisterDetail(account.employeeid)};cellAction.appendChild(btEmp)}}
if(response.length>=FILTER.pageItems){let newRowC=tableRef.insertRow(-1);newRowC.id="rowEmpBankRowAddMore";newRowC.setAttribute("class","noPrint borderGray font-size-x-large text-align-center");newRowC.style.cursor="pointer";let cellDescription=newRowC.insertCell(-1);cellDescription.innerHTML="<b>VER MAIS...</b>";cellDescription.setAttribute("colspan","7");newRowC.onclick=function(){employeeBankList(employeeId,FILTER.startIdx+FILTER.pageItems)}}
hideNotification()}
result()}};http.send(params)}
function employeeBankRgeisterOnLoad(){if(!setOnloadStatus("divEmployeeBankRegister",employeeBankRgeisterOnLoad)){return!1}
fillSelectNationalBank('selEmpBankRegNationalBank',-1);maskInputByPlaceHold("txtEmpBankRegAccountNumber");maskInputByPlaceHold("txtEmpBankRegIban")}
function employeeBankRegisterNew(account){if(!isNaN(Number(account.accountid))){setElementInnerHtml("h2EmpBankRegHeader","Dados da aplicação")}else{setElementInnerHtml("h2EmpBankRegHeader","Nova aplicação")}
showParts("divEmployeeBankRegister");setElementInnerHtml("lbEmpBankRegCurrentAccountId",account.accountid);setElementInnerHtml("lbEmpBankRegEmployeeId",account.employeeid);setElementInnerHtml("txtEmpBankRegEmployeeName",account.employeename);setElementValue("selEmpBankRegNationalBank",account.nationalbankid);setElementValue("txtEmpBankRegAccountNumber",account.accountnumber);setElementValue("txtEmpBankRegIban",account.iban);setElementValue("txtEmpBankRegStartDate",setLocalDate(account.startdate,10));setElementInnerHtml("lbEmpBankRegUpdate","Cadastrado por "+getOperatorName(account.operatorEntry,account.entryuser)+" em "+setLocalDate(account.entrydate,16)+". <br>"+"Actualizado por "+getOperatorName(account.operatorName,account.statususer)+" em "+setLocalDate(account.statusdate,16));dispatchOnInputChange()}
function employeeBankRegisterSave(){if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();FILTER.accountid=getElementInnerHTML("lbEmpBankRegCurrentAccountId");FILTER.employeeid=getElementInnerHTML("lbEmpBankRegEmployeeId");FILTER.nationalbankid=getElementValue("selEmpBankRegNationalBank");FILTER.accountnumber=reviewString(document.getElementById("txtEmpBankRegAccountNumber")).replace(/[^A-Z0-9\s\-]/g,"");FILTER.iban=getElementValue("txtEmpBankRegIban").replace(/[^0-9\AO\s]/g,"");FILTER.startdate=getElementValue("txtEmpBankRegStartDate");var mandatoryField=!1;var msg="";if(FILTER.employeeid==""){mandatoryField=!0;msg+="Deve indicar o trabalhador. <br>"}
if(Number(FILTER.nationalbankid)<=0){mandatoryField=!0;msg+="Deve indicar a categoria. <br>"}
if((FILTER.accountnumber=="")&&(FILTER.iban=="")){mandatoryField=!0;msg+="Deve indicar o número da conta ou o IBAN. <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=saveEmployeeBank"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_EMPLOYEE_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("divEmployeeBankRegister");employeeBankList(result.employeeid);setElementInnerHtml("lbEmpBankRegEmployeeId")}else{showNotification(result.msg,0)}}};http.send(params)}
function employeeBankDelete(account){function realDelete(){if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();FILTER.accountid=account.accountid;showNotification();var http=new XMLHttpRequest();var params="action=deleteEmployeeBank"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_EMPLOYEE_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 result=validateSession(http);if(result.status==!0){showNotification(result.msg,1);employeeBankList()}else{showNotification(result.msg,0)}}};http.send(params)}
showConfirm("Tem a certeza que deseja apagar esta conta bancária?",realDelete)}
function employeeAssignCategoryRegisterReceiveMessage(event){var response=event.data;if(response.status==1){showNotification(response.msg,1);if(response.wc=="EMPASSCATREG"){setElementInnerHtml("aEmpAssCatRegPhoto",response.tempfile);var aPhoto=document.getElementById("aEmpAssCatRegPhoto");aPhoto.href=URL_SRH_TEMP_FILE_X+response.tempfile}}else{showNotification(response.msg,0)}}
function employeeDepartmentRegisterReceiveMessage(event){var response=event.data;if(response.status==1){showNotification(response.msg,1);if(response.wc=="EMPDEPARTREG"){setElementInnerHtml("aEmpDepartRegPhoto",response.tempfile);var aPhoto=document.getElementById("aEmpDepartRegPhoto");aPhoto.href=URL_SRH_TEMP_FILE_X+response.tempfile}}else{showNotification(response.msg,0)}}
function setWorkscheduleAplicationType(type=-1){var list=[];list[0]="Tempo indeterminado";list[1]="Turno temporário";if(type!=-1){return list[Number(type)]}
return list}
function setEmployeeStatus(type=-1){var list=[];list[0]="Não processar";list[1]="Activo";if(type!=-1){return list[Number(type)]}
return list}
function myEmployeeAssignCategoryListOnLoad(){showNotification();setPageTitleWhoCall("0000","EMPCURCATLIST","Minha carreira");function cdoLoad(){var date=new Date();setElementValue("txtEmpAssCatListInitialDate",setLocalDate(new Date(date.getFullYear(),0,1),10));setElementValue("txtEmpAssCatListEndDate",setLocalDate(new Date(),10));setTriggerButtonByText('txtEmpAssCatListInitialDate','btEmpAssCatListViewAll');setTriggerButtonByText('txtEmpAssCatListEndDate','btEmpAssCatListViewAll');hideNotification()}
checkUserStatusAfterExecute(cdoLoad)}
function myEmployeeAssignCategoryList(startIdx=0){if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();FILTER.employeeId=SYSTEM_USER_STATUS.employeeId;FILTER.filterByDate=getElementChecked("chbEmpAssCatListShowDate");FILTER.initialDate=getElementValue('txtEmpAssCatListInitialDate');FILTER.endDate=getElementValue('txtEmpAssCatListEndDate');FILTER.sex="";FILTER.nationality=-1;FILTER.departmentId=-1;FILTER.categoryId=-1;FILTER.startIdx=startIdx;console.log(FILTER);if(ST_SRH_WAITING_SERVER==1){showNotification("Aguardando resposta do servidor. <br>",0);return!1}
let tableRef=document.getElementById("tblEmpAssCatListMainTable");if(FILTER.startIdx==0){tableRef.innerHTML=""}else{removeElement("rowEmpAssCatAddMore")}
showNotification();ST_SRH_WAITING_SERVER=1;var http=new XMLHttpRequest();var params="action=getEnployeeAssignCategoryList"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_EMPLOYEE_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 response=validateSession(http);var totalItems=response.length;if(totalItems>0){hideDivFilter()}
function result(){tableRef.innerHTML+=strFilterResult(response);setElementInnerHtml('lbResultOnList',FILTER.startIdx+response.length);var nRows=startIdx;for(var i=0;i<response.length;i++){let category=JSON.parse(response[i]);nRows+=1;let newRow=tableRef.insertRow(-1);newRow.setAttribute("id","rowEmpAssCatListRow"+category.currentcategoryid);newRow.setAttribute("class","borderGray"+setSelectedRowBackground("SELECTED_ROW_EMPLOYEE_ASSIGN_CATEGORY_LIST",newRow.id));let cellRow=createTableCell(newRow,nRows,"colRowNumber","#");let cellId=createTableCell(newRow,category.employeeid,"colProductId","Código");let cellAgent=createTableCell(newRow,leadingZero(category.agentnumberreal,4),"colProductId","Nº de agente");let cellName=createTableCell(newRow,category.employeename,"col-width-110","Nome completo");let cellCategory=createTableCell(newRow,category.category,"","Categoria / função");let cellDate=createTableCell(newRow,setLocalDate(category.startdate,10),"text-align-center colNoWrap ","Início de função");let cellCatTime=createTableCell(newRow,category.categorytime,"colProductId","Tempo na função");let cellUpdate=createTableCell(newRow,setLocalDate(category.statusdate,16),"colProductId","Última actualização")}
if(response.length>=FILTER.pageItems){let newRowC=tableRef.insertRow(-1);newRowC.id="rowEmpAssCatAddMore";newRowC.setAttribute("class","noPrint borderGray font-size-x-large text-align-center");newRowC.style.cursor="pointer";let cellDescription=newRowC.insertCell(-1);cellDescription.innerHTML="<b>VER MAIS...</b>";cellDescription.setAttribute("colspan","7");newRowC.onclick=function(){myEmployeeAssignCategoryList(FILTER.startIdx+FILTER.pageItems)}}
hideNotification()}
result()}};http.send(params)}
function myEmployeeBankListOnLoad(){showNotification();setPageTitleWhoCall("0000","EMPBANKLIST","Minhas Coordenadas Bancárias");function cdoLoad(){var date=new Date();setElementValue("txtEmpBankListInitialDate",setLocalDate(new Date(date.getFullYear(),0,1),10));setElementValue("txtEmpBankListEndDate",setLocalDate(new Date(),10));setTriggerButtonByText('txtEmpBankListInitialDate','btEmpBankListViewAll');setTriggerButtonByText('txtEmpBankListEndDate','btEmpBankListViewAll');myEmployeeBankList();hideNotification()}
checkUserStatusAfterExecute(cdoLoad)}
function myEmployeeBankList(startIdx=0){if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();FILTER.dependencyId=-1;FILTER.employeeId=SYSTEM_USER_STATUS.employeeId;FILTER.filterByDate=getElementChecked("chbEmpBankListShowDate");FILTER.initialDate=getElementValue('txtEmpBankListInitialDate');FILTER.endDate=getElementValue('txtEmpBankListEndDate');FILTER.bank=-1;FILTER.nationality=-1;FILTER.departmentId=-1;FILTER.categoryId=-1;FILTER.startIdx=startIdx;if(ST_SRH_WAITING_SERVER==1){showNotification("Aguardando resposta do servidor. <br>",0);return!1}
let tableRef=document.getElementById("tblEmpBankListMainTable");if(FILTER.startIdx==0){tableRef.innerHTML=""}else{removeElement("rowEmpBankRowAddMore")}
showNotification();ST_SRH_WAITING_SERVER=1;var http=new XMLHttpRequest();var params="action=getEnployeeBankList"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_EMPLOYEE_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 response=validateSession(http);var totalItems=response.length;if(totalItems>0){hideDivFilter()}
function result(){tableRef.innerHTML+=strFilterResult(response);setElementInnerHtml('lbResultOnList',FILTER.startIdx+response.length);var nRows=startIdx;for(var i=0;i<response.length;i++){let account=JSON.parse(response[i]);nRows+=1;let newRow=tableRef.insertRow(-1);newRow.setAttribute("id","rowEmpBankListRow"+account.accountid);newRow.setAttribute("class","borderGray"+setSelectedRowBackground("SELECTED_ROW_EMPLOYEE_BANK_LIST",newRow.id));let cellRow=createTableCell(newRow,nRows,"colRowNumber","#");let cellId=createTableCell(newRow,account.employeeid,"colProductId","Código");let cellAgent=createTableCell(newRow,leadingZero(account.agentnumberreal,4),"colProductId","Nº de agente");let cellName=createTableCell(newRow,account.employeename,"col-width-110","Nome completo");let cellBank=createTableCell(newRow,account.bank,"text-align-center","Banco");let cellAcc=createTableCell(newRow,account.accountnumber,"","Conta");let cellIban=createTableCell(newRow,account.iban,"","IBAN");let cellDate=createTableCell(newRow,setLocalDate(account.startdate,10),"text-align-center colNoWrap ","Início do contrato");let cellUpdate=createTableCell(newRow,setLocalDate(account.statusdate,16),"colProductId","Última actualização")}
if(response.length>=FILTER.pageItems){let newRowC=tableRef.insertRow(-1);newRowC.id="rowEmpBankRowAddMore";newRowC.setAttribute("class","noPrint borderGray font-size-x-large text-align-center");newRowC.style.cursor="pointer";let cellDescription=newRowC.insertCell(-1);cellDescription.innerHTML="<b>VER MAIS...</b>";cellDescription.setAttribute("colspan","7");newRowC.onclick=function(){myEmployeeBankList(FILTER.startIdx+FILTER.pageItems)}}
hideNotification()}
result()}};http.send(params)}
function employeeUserListOnLoad(){showNotification();setPageTitleWhoCall("4001-4002-4003","EMPUSELIS","Lista de trabalhadores vs utilizadores");function cdoLoad(){fillSelectDependencyFull("selEmpUseLisDependency",-1,1);fillSelectSex("selEmpUseLisSex",-1);fillSelectCountry("selEmpUseLisCountry",-1);fillSelectDepartment("selEmpUseLisDepartment",-1);fillSelectEmployeeCategory("selEmpUseLisEmployeeCategory",-1);var date=new Date();setElementValue("txtEmpUseLisInitialDate",setLocalDate(new Date(date.getFullYear(),date.getMonth(),1),10));setElementValue("txtEmpUseLisEndDate",setLocalDate(new Date(),10));setTriggerButtonByText('txtEmpUseLisInitialDate','btEmpUseLisViewAll');setTriggerButtonByText('txtEmpUseLisEndDate','btEmpUseLisViewAll');if(!checkPermission("4002")){removeElement("btEmpUseLisNewEmployee");removeElement("divEmployeeRegister")}
employeeSearchOnLoad();employeeRegisterOnLoad();systemUserSearchOnLoad();hideNotification()}
checkUserStatusAfterExecute(cdoLoad)}
function employeeUserList(employeeId=-1,startIdx=0){if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();FILTER.dependencyId=getElementValue("selEmpUseLisDependency");FILTER.employeeId=employeeId;FILTER.filterByDate=getElementChecked("chbContrLisShowDate");FILTER.initialDate=getElementValue('txtEmpUseLisInitialDate');FILTER.endDate=getElementValue('txtEmpUseLisEndDate');FILTER.sex=getElementValue("selEmpUseLisSex");FILTER.nationality=getElementValue("selEmpUseLisCountry");FILTER.departmentId=getElementValue("selEmpUseLisDepartment");FILTER.categoryId=getElementValue("selEmpUseLisEmployeeCategory");FILTER.startIdx=startIdx;if(ST_SRH_WAITING_SERVER==1){showNotification("Aguardando resposta do servidor. <br>",0);return!1}
let tableRef=document.getElementById("employeeListOnLoad");if(FILTER.startIdx==0){tableRef.innerHTML=""}else{removeElement("rowEmpUserRowAddMore")}
showNotification();ST_SRH_WAITING_SERVER=1;var http=new XMLHttpRequest();var params="action=getEmployeeList"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_EMPLOYEE_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 employees=validateSession(http);var totalItems=employees.length;if(totalItems>0){hideDivFilter()}
setElementInnerHtml('lbResultOnList',FILTER.startIdx+employees.length);function result(){tableRef.innerHTML+=strFilterResult(employees);var nRows=startIdx;for(var i=0;i<employees.length;i++){let employee=JSON.parse(employees[i]);nRows+=1;let newRow=tableRef.insertRow(-1);newRow.setAttribute("id","rowEmpList"+employee.employeeid);newRow.setAttribute("class","borderGray"+setSelectedRowBackground("SELECTED_ROW_EMPLOYEE_LIST",newRow.id));let cellRow=createTableCell(newRow,nRows,"colRowNumber","#");let cellId=createTableCell(newRow,employee.employeeid,"colProductId","Código");let cellAgent=createTableCell(newRow,leadingZero(employee.agentnumberreal,4),"colProductId","Nº de agente");let cellName=createTableCell(newRow,employee.employeename,"","Nome completo");let cellNat=createTableCell(newRow,employee.userfullname+" ("+employee.nodeuser+")","","Utilizador");let cellUpdate=createTableCell(newRow,setLocalDate(employee.statusdate,16),"colProductId","Última actualização");let cellOper=createTableCell(newRow,getFirtLastName(employee.operatorName)+" ("+employee.statususer+")","colProductId","Operador");let cellEdit=createTableCell(newRow,"","noPrint text-align-center","...");if(checkPermission("4002")){let btEdit=document.createElement("button");btEdit.setAttribute("class","labelEdit");btEdit.type="button";btEdit.onclick=function(){setSelectedRowOnClick(newRow,"SELECTED_ROW_EMPLOYEE_LIST");employeeUserAssignEdit(employee)};cellEdit.appendChild(btEdit);let btEmployee=document.createElement("button");btEmployee.innerHTML="Trabalhador";btEmployee.setAttribute("class","labelCustomer");btEmployee.type="button";btEmployee.onclick=function(){setSelectedRowOnClick(newRow,"SELECTED_ROW_EMPLOYEE_LIST");employeeRegisterDetail(employee.employeeid)};cellEdit.appendChild(btEmployee)}}
if(employees.length>=FILTER.pageItems){let newRowC=tableRef.insertRow(-1);newRowC.id="rowEmpUserRowAddMore";newRowC.setAttribute("class","noPrint borderGray font-size-x-large text-align-center");newRowC.style.cursor="pointer";let cellDescription=newRowC.insertCell(-1);cellDescription.innerHTML="<b>VER MAIS...</b>";cellDescription.setAttribute("colspan","7");newRowC.onclick=function(){employeeUserList(employeeId,FILTER.startIdx+FILTER.pageItems)}}
hideNotification()}
result()}};http.send(params)}
function employeeUserAssignEdit(employeeInfo){showParts("divEmployeeUserAssign");setElementInnerHtml("lbEmpUseAssRegEmployeeId",employeeInfo.employeeid);setElementInnerHtml("txtEmpUseAssRegEmployeeName",employeeInfo.employeename);setElementInnerHtml("txtEmpUseAssRegEmail",employeeInfo.email);setElementInnerHtml("txtEmpUseAssRegPhone",employeeInfo.phone1);fillSelectSystemUserBillingUser("selEmpUseAssRegNodeUser",-1,-1,employeeInfo.nodeuser);setElementFocus("selEmpUseAssRegNodeUser")}
function employeeUserAssingSave(){if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();var EMPLOYEE_BIOMETRIC_NEW=new _empWorkschedule();EMPLOYEE_BIOMETRIC_NEW.sessionId=FILTER.sessionId;EMPLOYEE_BIOMETRIC_NEW.sdk=FILTER.sdk;EMPLOYEE_BIOMETRIC_NEW.companyId=SYSTEM_USER_STATUS.companyId;EMPLOYEE_BIOMETRIC_NEW.dependencyId=SYSTEM_USER_STATUS.workplaceId;EMPLOYEE_BIOMETRIC_NEW.userId=SYSTEM_USER_STATUS.userId;EMPLOYEE_BIOMETRIC_NEW.employeeid=getElementInnerHTML("lbEmpUseAssRegEmployeeId");EMPLOYEE_BIOMETRIC_NEW.nodeuser=getElementValue("selEmpUseAssRegNodeUser");var mandatoryField=!1;var msg="";if(EMPLOYEE_BIOMETRIC_NEW.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=saveEmployeeUserAssign"+"&filterInfo="+JSON.stringify(EMPLOYEE_BIOMETRIC_NEW);var url=URL_SRH_EMPLOYEE_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("divEmployeeUserAssign");employeeUserList(EMPLOYEE_BIOMETRIC_NEW.employeeid);setElementInnerHtml("lbEmpUseAssRegEmployeeId")}else{showNotification(result.msg,0)}}};http.send(params)}
function employeeUserAssingTransformEmployee(){if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();FILTER.employeeid=getElementInnerHTML("lbEmpUseAssRegEmployeeId");FILTER.employeeName=getElementInnerHTML("txtEmpUseAssRegEmployeeName");FILTER.email=getElementInnerHTML("txtEmpUseAssRegEmail");FILTER.phone=getElementInnerHTML("txtEmpUseAssRegPhone");var mandatoryField=!1;var msg="";if(FILTER.employeeid==""){mandatoryField=!0;msg+="Deve indicar o trabalhador. <br>"}
if((FILTER.email=="")&&(FILTER.phone=="")){mandatoryField=!0;msg+="Deve indicar o e-mail ou telefone. <br>"}
if(FILTER.email!=""){if(!validateEmail(FILTER.email)){mandatoryField=!0;msg+="E-mail inválido. <br>"}}
if(FILTER.phone!=""){if((FILTER.phone.length!=9)||(!FILTER.phone.toString().startsWith("9"))){mandatoryField=!0;msg+="Telefone inválido. <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=saveEmployeeUserTransform"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_EMPLOYEE_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;console.log(http.responseText);var result=validateSession(http);if(result.status==!0){showNotification(result.msg,1);hideParts("divEmployeeUserAssign");employeeUserList(FILTER.employeeid);setElementInnerHtml("lbEmpUseAssRegEmployeeId")}else{showNotification(result.msg,0)}}};http.send(params)}
function employeeScheduleImportNew(){showParts("divEmployeeWorkscheduleImport");setElementInnerHtml("lbEmpSchImpFilename");setElementInnerHtml("tblEmpSchImpPreviewTable");var iFrame=document.getElementById("iframeEmpSchImpUploadFile");iFrame.src+="&a"+randomString(3)+"="+randomString(3)}
function employeeScheduleImportReceiveMessage(event){var response=event.data;if(response.status==1){showNotification(response.msg,1);setElementInnerHtml("lbEmpSchImpFilename",response.tempfile);var numberOfLines=response.numberoflines;setElementInnerHtml("txtEmpSchImpNumberOfLines",numberOfLines);setElementValue("txtEmpSchImpLastLine",numberOfLines);setElementInnerHtml("lbEmpSchImpFirstLine",response.firstline);setElementInnerHtml("lbEmpSchImpContent",response.content);employeeScheduleImportReviewContent()}else{showNotification(response.msg,0)}}
function employeeScheduleImportReviewContent(){var separator=getElementValue("selEmpSchImpColumnSeparator");var firstLine=getElementInnerHTML("lbEmpSchImpFirstLine").toString().split(separator);var trHeader=document.getElementById("trEmpSchImpPreviewHeader");trHeader.innerHTML="";var tbl=document.getElementById("tblEmpSchImpPreviewTable");tbl.innerHTML="";let thrn=createElement("th");thrn.innerHTML="#";trHeader.appendChild(thrn);for(var i=1;i<=firstLine.length;i++){let th=createElement("th");th.innerHTML=i;trHeader.appendChild(th)}
var content=getElementInnerHTML("lbEmpSchImpContent").toString().split("\n");var nRow=0;for(var r=0;r<content.length;r++){nRow+=1;let rwCont=content[r].toString().split(separator);let newRow=tbl.insertRow(-1);newRow.style.fontSize="small";let cellrn=createTableCell(newRow,nRow,"colRowNumber");for(var c=0;c<rwCont.length;c++){let cell=createTableCell(newRow,rwCont[c],"text-align-center")}}}
function employeeScheduleImportResume(){if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();FILTER.separator=getElementValue("selEmpSchImpColumnSeparator");FILTER.employeeIdCol=Number(getElementValue("txtEmpSchImpEmployeeId"))-1;FILTER.profIdCol=Number(getElementValue("txtEmpSchImpProfId"))-1;FILTER.nameCol=Number(getElementValue("txtEmpSchImpName"))-1;FILTER.academicYearCol=Number(getElementValue("txtEmpSchImpAcademicYear"))-1;FILTER.weekDayCol=Number(getElementValue("txtEmpSchImpWeekDay"))-1;FILTER.timeCol=Number(getElementValue("txtEmpSchImpTime"))-1;FILTER.startTimeCol=Number(getElementValue("txtEmpSchImpStartTime"))-1;FILTER.endTimeCol=Number(getElementValue("txtEmpSchImpEndTime"))-1;FILTER.classindicatorCol=Number(getElementValue("txtEmpSchImpClassIndicator"))-1;FILTER.subjectCol=Number(getElementValue("txtEmpSchImpSubject"))-1;FILTER.firstLine=Number(getElementValue("txtEmpSchImpFirstLine"));FILTER.lastLine=Number(getElementValue("txtEmpSchImpLastLine"));FILTER.fileName=getElementInnerHTML("lbEmpSchImpFilename");var mandatoryField=!1;var msg="";if(FILTER.fileName==""){mandatoryField=!0;msg+="Deve carregar um ficheiro. <br>"}
if(FILTER.employeeIdCol<0){mandatoryField=!0;msg+="Coluna do código não deve ser inferior a 0. <br>"}
if(FILTER.profIdCol<0){mandatoryField=!0;msg+="Coluna do prof id não deve ser inferior a 0. <br>"}
if(FILTER.nameCol<0){mandatoryField=!0;msg+="Coluna do nome não deve ser inferior a 0. <br>"}
if(FILTER.academicYearCol<0){mandatoryField=!0;msg+="Coluna do ano lectivo não deve ser inferior a 0. <br>"}
if(FILTER.weekDayCol<0){mandatoryField=!0;msg+="Coluna do dia da semana não deve ser inferior a 0. <br>"}
if(FILTER.timeCol<0){mandatoryField=!0;msg+="Coluna do tempo não deve ser inferior a 0. <br>"}
if(FILTER.startTimeCol<0){mandatoryField=!0;msg+="Coluna do início não deve ser inferior a 0. <br>"}
if(FILTER.endTimeCol<0){mandatoryField=!0;msg+="Coluna do término não deve ser inferior a 0. <br>"}
if(FILTER.classindicatorCol<0){mandatoryField=!0;msg+="Coluna da turma não deve ser inferior a 0. <br>"}
if(FILTER.subjectCol<0){mandatoryField=!0;msg+="Coluna da disciplina não deve ser inferior a 0. <br>"}
if(ST_SRH_WAITING_SERVER==1){mandatoryField=!0;msg+="Aguardando resposta do servidor. <br>"}
if(mandatoryField){alert(msg);return!1}
let tableRef=document.getElementById("tblEmpSchImpResume");tableRef.innerHTML="";showNotification();ST_SRH_WAITING_SERVER=1;var http=new XMLHttpRequest();var params="action=getEmployeeWorkscheduleImportResumeList"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_EMPLOYEE_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);var nRows=0;Array.from(result).forEach(employee=>{nRows+=1;let newRow=tableRef.insertRow(-1);newRow.setAttribute("class","borderGray");createTableCell(newRow,nRows,"colRowNumber","#");createTableCell(newRow,employee.name,"col-width-110","Nome no ficheiro");createTableCell(newRow,employee.employeeid,"text-align-center","Código");createTableCell(newRow,employee.employeename,"col-width-110","Nome na base de dados");var status=(employee.employeename=="")?"Não será importado":"";createTableCell(newRow,status,"text-align-center","Código")});hideNotification();showParts("divEmployeeWorkscheduleImportResume")}};http.send(params)}
function employeeScheduleImportSave(){if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();var mandatoryField=!1;var msg="";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=getEmployeeWorkscheduleImportSave"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_EMPLOYEE_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);var nRows=0;Array.from(result).forEach(employee=>{nRows+=1;let newRow=tableRef.insertRow(-1);newRow.setAttribute("class","borderGray");createTableCell(newRow,nRows,"colRowNumber","#");createTableCell(newRow,employee.name,"col-width-110","Nome no ficheiro");createTableCell(newRow,employee.employeeid,"text-align-center","Código");createTableCell(newRow,employee.employeename,"col-width-110","Nome na base de dados");var status=(employee.employeename=="")?"Não será importado":"";createTableCell(newRow,status,"text-align-center","Código")});hideNotification();showParts("divEmployeeWorkscheduleImportResume")}};http.send(params)}
function employeeBiometricDeviceTransferNew(){showParts("divEmployeeBiometricDeviceTransfer");fillSelectBiometricDevice("selEmpBioDevTransBiometric",-1);fillSelectBiometricDevice("selEmpBioDevTransBioEmployee",-1)}
function employeeBiometricDeviceTransferSave(){if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();FILTER.biometricId=getElementValue("selEmpBioDevTransBiometric");FILTER.bioEmployee=getElementValue("selEmpBioDevTransBioEmployee");var mandatoryField=!1;var msg="";if(FILTER.biometricId==-1){mandatoryField=!0;msg+="Deve indicar um dispositivo biométrico. <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=saveEmployeeBiometricDeviceTransfer"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_EMPLOYEE_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;console.log(http.responseText);var result=validateSession(http);if(result.status==!0){alert(result.msg);hideParts("divEmployeeBiometricDeviceTransfer");hideNotification()}else{showNotification(result.msg,0)}}};http.send(params)}