function pointControlBimetricDeviceListOnLoad(){showNotification();setPageTitleWhoCall("4106","BIODEVLIS","Lista de dispositivos biométricos");function cdoLoad(){pointControlBiometricDeviceList();hideNotification()}
checkUserStatusAfterExecute(cdoLoad)}
function pointControlBiometricDeviceNew(){pointControlBiometricDeviceDetail()}
function pointControlBiometricDeviceDetail(biometricId=-1){showParts("divBiometricDeviceRegister");const lbHeader=document.getElementById("h2BioDevRegHeader");const txtBiometricId=document.getElementById("txtBioDevRegBiometricId");const txtBrand=document.getElementById("txtBioDevRegBrand");const txtLocation=document.getElementById("txtBioDevRegLocation");const txtLocalIP=document.getElementById("txtBioDevRegLocalIp");const lbUpdate=document.getElementById("lbBioDevRegUpdate");if(biometricId==-1){lbHeader.innerHTML="Novo dispositivo biométrico";txtBiometricId.value="Novo dispositivo *";txtBrand.value="";txtLocation.value="";txtLocalIP.value="";lbUpdate.innerHTML="Actualizado em "+setLocalDate(new Date(),16)}else{lbHeader.innerHTML="Dados do dispositivo biométrico";if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();FILTER.biometricId=biometricId;showNotification();var http=new XMLHttpRequest();var params="action=getBiometricDeviceList"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_POINT_CONTROL_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);let biometric=JSON.parse(response[0]);txtBiometricId.value=biometric.biometricid;txtBrand.value=biometric.brand;txtLocation.value=biometric.location;txtLocalIP.value=biometric.localip;lbUpdate.innerHTML="Cadastrado por "+getOperatorName(biometric.operatorEntry,biometric.entryuser)+" em "+setLocalDate(biometric.entrydate,16)+". <br>"+"Actualizado por "+getOperatorName(biometric.operatorName,biometric.statususer)+" em "+setLocalDate(biometric.statusdate,16);hideNotification()}};http.send(params)}
setAutoCompleteToFiel(txtBrand.id,50,1);setAutoCompleteToFiel(txtLocation.id,51,1);txtBrand.focus()}
function pointControlBiometricDeviceRegisterSave(){if(!desktopSecurityCheck()){return!1}
var BIOMETRIC_NEW=setFilterStatus();BIOMETRIC_NEW.biometricid=getElementValue("txtBioDevRegBiometricId");BIOMETRIC_NEW.brand=reviewString(document.getElementById("txtBioDevRegBrand")).toUpperCase();BIOMETRIC_NEW.location=reviewString(document.getElementById("txtBioDevRegLocation")).toUpperCase();BIOMETRIC_NEW.localip=reviewString(document.getElementById("txtBioDevRegLocalIp")).toUpperCase();var mandatoryField=!1;var msg="";if(BIOMETRIC_NEW.brand==""){mandatoryField=!0;msg+="Deve indicar a marca / modelo / número de série do dispositivo. <br>"}
if(BIOMETRIC_NEW.localip!=""){if(!validateIPaddress(BIOMETRIC_NEW.localip)){mandatoryField=!0;msg+="Ip local fora do formato. <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=saveBiometricDeviceInformation"+"&filterInfo="+JSON.stringify(BIOMETRIC_NEW);var url=URL_SRH_POINT_CONTROL_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("divBiometricDeviceRegister");if(ST_SRH_MAIN_WHO_CALL=="BIODEVLIS"){pointControlBiometricDeviceList()}else if(ST_SRH_MAIN_WHO_CALL=="EMPLIS"){fillSelectBiometricDevice("selEmpRegBiometricoId",-1,getElementValue("selEmpRegBiometricoId"))}else if(ST_SRH_MAIN_WHO_CALL=="EMPBIODEV"){fillSelectBiometricDevice("selEmpBioDevRegBiometric",-1,getElementValue("selEmpBioDevRegBiometric"))}}else{showNotification(result.msg,0)}}};http.send(params)}
function pointControlBiometricDeviceRegisterTestIp(){if(!desktopSecurityCheck()){return!1}
var BIOMETRIC_NEW=setFilterStatus();BIOMETRIC_NEW.localip=reviewString(document.getElementById("txtBioDevRegLocalIp")).toUpperCase();var mandatoryField=!1;var msg="";if(!validateIPaddress(BIOMETRIC_NEW.localip)){mandatoryField=!0;msg+="Ip local fora do formato. <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=getBiometricDeviceTest"+"&filterInfo="+JSON.stringify(BIOMETRIC_NEW);var url=URL_SRH_POINT_CONTROL_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)}else{showNotification(result.msg,0)}}};http.send(params)}
function pointControlBiometricDeviceList(){if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();FILTER.biometricId=-1;if(ST_SRH_WAITING_SERVER==1){showNotification("Aguardando resposta do servidor. <br>");return!1}
let tableRef=document.getElementById("tblBioDevListMainTable");tableRef.innerHTML=strFilterResult();showNotification();ST_SRH_WAITING_SERVER=1;var http=new XMLHttpRequest();var params="action=getBiometricDeviceList"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_POINT_CONTROL_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);tableRef.innerHTML=strFilterResult(response);setElementInnerHtml("lbResultOnList",response.length);var nRows=0;for(var i=0;i<response.length;i++){let biometric=JSON.parse(response[i]);nRows+=1;let newRow=tableRef.insertRow(-1);newRow.setAttribute("id","rowBioDevList"+biometric.biometricid);newRow.setAttribute("class","borderGray"+setSelectedRowBackground("SELECTED_ROW_BIOMETRIC_DEVICE_LIST",newRow.id));createTableCell(newRow,nRows,"colRowNumber","#");createTableCell(newRow,biometric.biometricid,"colProductId","Código");createTableCell(newRow,biometric.brand,"","Marca / Modelo");createTableCell(newRow,biometric.location,"","Localização");createTableCell(newRow,biometric.localip,"text-align-center","IP Local");createTableCell(newRow,biometric.employees,"text-align-center","Trabalhadores");createTableCell(newRow,setLocalDate(biometric.statusdate,16),"colProductId","Última actualização");createTableCell(newRow,getFirtLastName(biometric.operatorName)+" ("+biometric.statususer+")","colProductId","Código");let cellEdit=createTableCell(newRow,"","noPrint text-align-center","...");let btEdit=document.createElement("button");btEdit.setAttribute("class","labelEdit");btEdit.type="button";btEdit.name=biometric.biometricid;btEdit.onclick=function(){setSelectedRowOnClick(newRow,"SELECTED_ROW_BIOMETRIC_DEVICE_LIST");pointControlBiometricDeviceDetail(btEdit.name)};cellEdit.appendChild(btEdit);let btDelete=document.createElement("button");btDelete.setAttribute("class","labelDelete");btDelete.type="button";btDelete.onclick=function(){setSelectedRowOnClick(newRow,"SELECTED_ROW_BIOMETRIC_DEVICE_LIST");pointControlBiometricDeviceRegisterDelete(biometric.biometricid)};cellEdit.appendChild(btDelete)}}};http.send(params)}
function pointControlBiometricDeviceRegisterDelete(biometricId){function realDelete(){if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();FILTER.biometricId=biometricId;showNotification();var http=new XMLHttpRequest();var params="action=deleteBiometricDevice"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_POINT_CONTROL_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);pointControlBiometricDeviceList()}else{showNotification(result.msg,0)}}};http.send(params)}
showConfirm("Tem a certeja que deseja apagar este dispositivo biométrico?<br><br>",realDelete)}
function pointControlActivityOnLoad(){showNotification();setPageTitleWhoCall("4100","POICONACTLIS","Registo de actividade");function cdoLoad(){fillSelectDependencyFull("selPoiConActListDependency",-1,1);fillSelectBiometricDevice("selPoiConActListBiometric",-1);fillSelectWorkschedule("selPoiConActListWorkschedule",-1);fillSelectDepartment("selPoiConActListDepartment",-1);fillSelectEmployeeCategory("selPoiConActListEmployeeCategory",-1);fillSelectWorkscheduleAplicationType("selEmpWorSchRegAplicationType",1,0);var date=new Date();setElementValue("txtPoiConActListInitialDate",setLocalDate(new Date(date.getFullYear(),date.getMonth(),1),10));setElementValue("txtPoiConActListEndDate",setLocalDate(new Date(),10));setTriggerButtonByText('txtPoiConActListInitialDate','btPoiConActListViewAll');setTriggerButtonByText('txtPoiConActListEndDate','btPoiConActListViewAll');document.getElementById("btPoiConActImportRecord").onclick=function(){pointControlActivityLoadNew(getElementValue("txtPoiConActListInitialDate"),getElementValue("txtPoiConActListEndDate"))};if(!checkPermission("4002")){removeElement("btPoiConActListNewEmployee");removeElement("divEmployeeRegister")}
if(!checkPermission("4101")){removeElement("btPoiConActListDeleteAll")}
if(!checkPermission("4111")){removeElement("btEmpWorSchRegWorkscheduleNew");removeElement("divWorkscheduleRegister")}
employeeSearchOnLoad();employeeRegisterOnLoad();hideNotification()}
checkUserStatusAfterExecute(cdoLoad)}
function pointControlActivityLoadNew(initalDate,endDate){showParts("divPointControlActivityLoad");fillSelectBiometricDevice("selPoiConActLoadBiometric",-1);setElementValue("txtPoiConActLoadInitialDate",initalDate);setElementValue("txtPoiConActLoadEndDate",endDate);setElementInnerHtml("lbPoiConActLoadFilename");setElementInnerHtml("tblPoiConActLoadPreviewTable");var iFrame=document.getElementById("iframePoiConActLoadUploadFile");iFrame.src+="&a"+randomString(3)+"="+randomString(3)}
function pointActivityLoadReceiveMessage(event){var response=event.data;if(response.status==1){showNotification(response.msg,1);setElementInnerHtml("lbPoiConActLoadFilename",response.tempfile);var numberOfLines=response.numberoflines;setElementInnerHtml("txtPoiConActLoadNumberOfLines",numberOfLines);setElementValue("txtPoiConActLoadLastLine",numberOfLines);setElementInnerHtml("lbPoiConActLoadFirstLine",response.firstline);setElementInnerHtml("lbPoiConActLoadContent",response.content);pointActivityLoadReviewContent()}else{showNotification(response.msg,0)}}
function pointActivityLoadReviewContent(){var separator=getElementValue("selPoiConActLoadColumnSeparator");var firstLine=getElementInnerHTML("lbPoiConActLoadFirstLine").toString().split(separator);var trHeader=document.getElementById("trPoiConActLoadPreviewHeader");trHeader.innerHTML="";var tbl=document.getElementById("tblPoiConActLoadPreviewTable");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("lbPoiConActLoadContent").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 pointControlActivityLoadSave(){if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();FILTER.initialDate=getElementValue("txtPoiConActLoadInitialDate");FILTER.endDate=getElementValue("txtPoiConActLoadEndDate");FILTER.separator=getElementValue("selPoiConActLoadColumnSeparator");FILTER.biometricId=getElementValue("selPoiConActLoadBiometric");FILTER.identificstionCol=Number(getElementValue("txtPoiConActLoadBiometricIdentification"))-1;FILTER.recordType=getElementValue("selPoiConActLoadRecordType");FILTER.dateTimeCol=Number(getElementValue("txtPoiConActLoadDateTimeCol"))-1;FILTER.dateCol=Number(getElementValue("txtPoiConActLoadDateCol"))-1;FILTER.timeCol=Number(getElementValue("txtPoiConActLoadTimeCol"))-1;FILTER.firstLine=Number(getElementValue("txtPoiConActLoadFirstLine"));FILTER.lastLine=Number(getElementValue("txtPoiConActLoadLastLine"));FILTER.fileName=getElementInnerHTML("lbPoiConActLoadFilename");var mandatoryField=!1;var msg="";if(FILTER.fileName==""){mandatoryField=!0;msg+="Deve carregar um ficheiro. <br>"}
if((FILTER.biometricId=="")||(FILTER.biometricId==-1)){mandatoryField=!0;msg+="Deve indicar o dispositivo biomátrico de origem. <br>"}
if(FILTER.identificstionCol<0){mandatoryField=!0;msg+="Coluna do identificador único não deve ser inferior a 0. <br>"}
if(FILTER.recordType==1){if(FILTER.identificstionCol==FILTER.dateTimeCol){mandatoryField=!0;msg+="Coluna do identificador único deve ser diferente da Coluna da data e hora. <br>"}
if(FILTER.dateTimeCol<0){mandatoryField=!0;msg+="Coluna da data e hora não deve ser inferior a 0. <br>"}}else{if((FILTER.identificstionCol==FILTER.dateCol)||(FILTER.identificstionCol==FILTER.timeCol)||(FILTER.dateCol==FILTER.timeCol)){mandatoryField=!0;msg+="Coluna do identificador único, Coluna da data, e Coluna da hora devem ser difrentes. <br>"}
if((FILTER.dateCol<0)||(FILTER.timeCol<0)){mandatoryField=!0;msg+="CColuna da data, e Coluna da hora não devem ser inferior a 0. <br>"}}
if(dateDiffDays(FILTER.endDate,FILTER.initialDate)>12){mandatoryField=!0;msg+="O Intervalo entre as datas de importação não deve ser superior a 12 dias. <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=savePointControlActiviteLoad"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_POINT_CONTROL_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){alert(result.msg);hideNotification();hideParts("divPointControlActivityLoad");if(ST_SRH_MAIN_WHO_CALL=="POICONACTLIS"){setElementValue("txtPoiConActListInitialDate",FILTER.initialDate);setElementValue("txtPoiConActListEndDate",FILTER.endDate);pointControlActivityList()}}else{showNotification(result.msg,0)}}};http.send(params)}
function pointControlActivityList(employeeId=-1,startIdx=0){if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();FILTER.dependencyId=getElementValue("selPoiConActListDependency");FILTER.employeeId=employeeId;FILTER.initialDate=getElementValue('txtPoiConActListInitialDate');FILTER.endDate=getElementValue('txtPoiConActListEndDate');FILTER.biometricId=getElementValue('selPoiConActListBiometric');FILTER.workscheduleId=getElementValue('selPoiConActListWorkschedule');FILTER.departmentId=getElementValue("selPoiConActListDepartment");FILTER.categoryId=getElementValue("selPoiConActListEmployeeCategory");FILTER.viewMode=1;FILTER.startIdx=startIdx;if(ST_SRH_WAITING_SERVER==1){showNotification("Aguardando resposta do servidor. <br>");return!1}
let tableRef=document.getElementById("tblPoiConActListMainTable");if(FILTER.startIdx==0){tableRef.innerHTML=""}else{removeElement("rowPoiConActAddMore")}
showNotification();ST_SRH_WAITING_SERVER=1;var http=new XMLHttpRequest();var params="action=getPointControlActivityList"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_POINT_CONTROL_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","rowPoiConActList"+employee.id);newRow.setAttribute("class","borderGray"+setSelectedRowBackground("SELECTED_ROW_POINT_CONTROL_ACTIVITY_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,"headcol","Nome completo");let cellDate=createTableCell(newRow,setLocalDate(employee.registertime,10),"text-align-center colNoWrap","Data");let cellTime=createTableCell(newRow,setLocalDate(employee.registertime,16).slice(11),"text-align-center colNoWrap","Hora");let cellBio=createTableCell(newRow,employee.brand,"text-align-center","Dispositivo biométrico");let cellIdentif=createTableCell(newRow,employee.biometricidentification,"text-align-center","Identificador Único");let cellWorkSche=createTableCell(newRow,employee.workschedule,"text-align-center font-size-small","Turno");let cellCategory=createTableCell(newRow,employee.category,"text-align-center font-size-small","Categoria / função");let cellDepart=createTableCell(newRow,employee.department,"text-align-center font-size-small","Posto de trabalho");let cellDelete=createTableCell(newRow,"","noPrint text-align-center","...");if(checkPermission("4101")){let btDelete=document.createElement("button");btDelete.setAttribute("class","labelDelete");btDelete.type="button";btDelete.onclick=function(){setSelectedRowOnClick(newRow,"SELECTED_ROW_POINT_CONTROL_ACTIVITY_LIST");pointControlActivityDelete(employee)};cellDelete.appendChild(btDelete)}}
if(response.length>=FILTER.pageItems){let newRowC=tableRef.insertRow(-1);newRowC.id="rowPoiConActAddMore";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(){pointControlActivityList(employeeId,FILTER.startIdx+FILTER.pageItems)}}
hideNotification()}
result()}};http.send(params)}
function pointControlActivityDelete(activity){function realDelete(){if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();FILTER.employeeid=activity.employeeid;FILTER.biometricid=activity.biometricid;FILTER.biometricidentification=activity.biometricidentification;FILTER.registertime=activity.registertime;showNotification();var http=new XMLHttpRequest();var params="action=deletePointControlActivity"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_POINT_CONTROL_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);pointControlActivityList()}else{showNotification(result.msg,0)}}};http.send(params)}
showConfirm("Tem a certeja que deseja apagar este registo?<br><br>",realDelete)}
function pointControlPointOnLoad(){showNotification();setPageTitleWhoCall("4102-4103-4104","POICONPOILIS","Controlo do ponto");function cdoLoad(){fillSelectDependencyFull("selPoiConPoiListDependency",-1,1);fillSelectWorkschedule("selPoiConPoiListWorkschedule",-1);fillSelectDepartment("selPoiConPoiListDepartment",-1);fillSelectEmployeeCategory("selPoiConPoiListEmployeeCategory",-1);fillSelectWorkscheduleAplicationType("selEmpWorSchRegAplicationType",1,0);var today=new Date();setElementValue("txtPoiConPoiListInitialDate",setLocalDate(dateAddDays(today,-15),10));setElementValue("txtPoiConPoiListEndDate",setLocalDate(today,10));setTriggerButtonByText('txtPoiConPoiListInitialDate','btPoiConPoiListViewAll');setTriggerButtonByText('txtPoiConPoiListEndDate','btPoiConPoiListViewAll');document.getElementById("btPoiConPoiListImportRecord").onclick=function(){pointControlActivityLoadNew(getElementValue("txtPoiConPoiListInitialDate"),getElementValue("txtPoiConPoiListEndDate"))};if(!checkPermission("4100")){removeElement("btPoiConPoiListSinchActivity");removeElement("btPoiConPoiListImportRecord")}
if(!checkPermission("4102")){removeElement("btPoiConPoinFault")}
if(!checkPermission("4002")){removeElement("btPoiConPoiListNewEmployee");removeElement("divEmployeeRegister")}
if(!checkPermission("4111")){removeElement("btEmpWorSchRegWorkscheduleNew");removeElement("divWorkscheduleRegister")}
if(!checkPermission("4105")){removeElement("btPoiConPoiListFaultReport")}
if(!checkPermission("4103")){removeElement("btPoiConPoinFaultJustify");removeElement("btPoiConPoinDelayJustify")}
if(!checkPermission("4104")){removeElement("btPoiConPoiListAttendeceAll");removeElement("btPoiConPoiListClearFault");removeElement("btPoiConPoinFaultCancel");removeElement("btPoiConPoinDelayCancel")}
employeeSearchOnLoad();employeeRegisterOnLoad();hideNotification()}
checkUserStatusAfterExecute(cdoLoad)}
function pointControlPointList(employeeId=-1,startIdx=0,fromSave=0){if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();FILTER.dependencyId=getElementValue("selPoiConPoiListDependency");FILTER.userId=SYSTEM_USER_STATUS.userId;FILTER.employeeId=employeeId;FILTER.initialDate=getElementValue('txtPoiConPoiListInitialDate');FILTER.endDate=getElementValue('txtPoiConPoiListEndDate');FILTER.sex="";FILTER.workscheduleId=getElementValue('selPoiConPoiListWorkschedule');FILTER.departmentId=getElementValue("selPoiConPoiListDepartment");FILTER.categoryId=getElementValue("selPoiConPoiListEmployeeCategory");FILTER.viewMode=2;FILTER.fromSave=fromSave;FILTER.startIdx=startIdx;if(!getDesktopStatus()){var dd=dateDiffDays(FILTER.endDate,FILTER.initialDate);if(dd>16){showNotification('O intervalo entre as datas não pode ser superior a 16 dias.',0);return!1}}
if(ST_SRH_WAITING_SERVER==1){showNotification("Aguardando resposta do servidor. <br>");return!1}
let tableRef=document.getElementById("tblPoiConPoiListMainTable");if(FILTER.startIdx==0){tableRef.innerHTML=""}else{removeElement("rowPoiConGenAddMore")}
showNotification();ST_SRH_WAITING_SERVER=1;var http=new XMLHttpRequest();var params="action=getWorkschedulePointList"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_WORKSCHEDULE_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 workDayOld="";var nRows=startIdx;var nEmp=1;var oldEmployeeId="";for(var i=0;i<response.length;i++){let employee=JSON.parse(response[i]);let currEmployeeId=employee.employeeid+"_"+setLocalDate(employee.workday,10).toString().replace("-","");var currWorkDay=employee.workday;nRows+=1;if(workDayOld!=currWorkDay){let rowDay=tableRef.insertRow(-1);rowDay.setAttribute("class","borderGray font-size-x-large font-weight-bold");let cellRowDay=createTableCell(rowDay,dateExtension(employee.workday),"text-align-center");cellRowDay.setAttribute("colspan","4")}
workDayOld=currWorkDay;if(oldEmployeeId!=currEmployeeId){let newRow=tableRef.insertRow(-1);newRow.setAttribute("id","rowPoiConPoiList"+currEmployeeId);newRow.setAttribute("class","borderGray"+setSelectedRowBackground("SELECTED_ROW_POINT_CONTROL_POINT_LIST",newRow.id));let cellRow=createTableCell(newRow,nRows,"colRowNumber","#");cellRow.setAttribute("id","rowPoiConActListCellRow"+currEmployeeId);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,"col-width-150 headcol","Nome completo");let cellWorkSche=createTableCell(newRow,"","","Turno");let divWorksche=createElement("div","","text-align-center font-size-small");divWorksche.innerHTML=employee.workschedule;cellWorkSche.appendChild(divWorksche);let cellDay=createTableCell(newRow,setLocalDate(employee.workday,10).toString().substr(8,2),"text-align-center colNoWrap font-weight-bold","Dia");let cellDesc=createTableCell(newRow,"","font-size-small","Estado");cellDesc.setAttribute("id","rowPoiConActListCellDescription"+currEmployeeId);let cellStatus=createTableCell(newRow,"","","Estado");cellStatus.setAttribute("id","rowPoiConActListCellStatus"+currEmployeeId);let cellStartPlan=createTableCell(newRow,"","","Entrada prevista");cellStartPlan.setAttribute("id","rowPoiConActListCellSyartPla"+currEmployeeId);let cellStartReg=createTableCell(newRow,"","","Entrada registada");cellStartReg.setAttribute("id","rowPoiConActListCellStartReg"+currEmployeeId);let cellEndPlan=createTableCell(newRow,"","","Saída prevista");cellEndPlan.setAttribute("id","rowPoiConActListCellEndPlan"+currEmployeeId);let cellEndReg=createTableCell(newRow,"","","Saída registada");cellEndReg.setAttribute("id","rowPoiConActListCellEndReg"+currEmployeeId);let cellWorkTime=createTableCell(newRow,"","","Tempo de trabalho");cellWorkTime.setAttribute("id","rowPoiConActListCellWorkTime"+currEmployeeId);let cellFault=createTableCell(newRow,"","","Falta");cellFault.setAttribute("id","rowPoiConActListCellFault"+currEmployeeId);let cellDelay=createTableCell(newRow,"","","Tempo de atraso");cellDelay.setAttribute("id","rowPoiConActListCellDelay"+currEmployeeId);let cellExtraTime=createTableCell(newRow,"","","Horas extras");cellExtraTime.setAttribute("id","rowPoiConActListCellExtra"+currEmployeeId);let cellEdit=createTableCell(newRow,"","noPrint text-align-center","...");cellEdit.setAttribute("id","rowPoiConActListCellEdit"+currEmployeeId)}
oldEmployeeId=currEmployeeId;var dvStyle="margin-top: 3px;";var cellDescrX=document.getElementById("rowPoiConActListCellDescription"+currEmployeeId);let divDescr=createElement("div","","row-height-10",dvStyle+" font-size: x-small;");divDescr.innerHTML=(employee.description);cellDescrX.appendChild(divDescr);var bgc=(employee.workdaystatus==2)?" background-color-brown":"";var cellStatusX=document.getElementById("rowPoiConActListCellStatus"+currEmployeeId);let divStatus=createElement("div","","row-height-10 text-align-center colNoWrap"+bgc,dvStyle);divStatus.innerHTML=pointControlWorkDayStatus(employee.workdaystatus);cellStatusX.appendChild(divStatus);var cellStartPlanX=document.getElementById("rowPoiConActListCellSyartPla"+currEmployeeId);let divStartPlan=createElement("div","","row-height-10 text-align-center color-gray",dvStyle);divStartPlan.innerHTML=setLocalDate(employee.starttimeplanned,16).slice(11);cellStartPlanX.appendChild(divStartPlan);var cellStartRegX=document.getElementById("rowPoiConActListCellStartReg"+currEmployeeId);let divStartReg=createElement("div","","row-height-10 text-align-center font-weight-bold",dvStyle);divStartReg.innerHTML=employee.starttime;cellStartRegX.appendChild(divStartReg);var cellEndPlanX=document.getElementById("rowPoiConActListCellEndPlan"+currEmployeeId);let divEndPlan=createElement("div","","row-height-10 text-align-center color-gray",dvStyle);divEndPlan.innerHTML=setLocalDate(employee.endtimeplanned,16).slice(11);cellEndPlanX.appendChild(divEndPlan);var cellEndRegX=document.getElementById("rowPoiConActListCellEndReg"+currEmployeeId);let divEndReg=createElement("div","","row-height-10 text-align-center font-weight-bold",dvStyle);divEndReg.innerHTML=employee.endtime;cellEndRegX.appendChild(divEndReg);var cellWorkTimeX=document.getElementById("rowPoiConActListCellWorkTime"+currEmployeeId);let divWorkTime=createElement("div","","row-height-10 text-align-center  color-gray",dvStyle);divWorkTime.innerHTML=sec2time(Number(employee.workduration)*60,!0,!1);cellWorkTimeX.appendChild(divWorkTime);bgc=(Number(employee.faultstatus)<1)?"":(employee.faultstatus==1)?" background-color-red-accent":(employee.faultstatus==2)?" background-color-red-primary":" background-color-red-primary-dark";var cellFaultX=document.getElementById("rowPoiConActListCellFault"+currEmployeeId);let divFault=createElement("div","","row-height-10 colNoWrap text-align-center font-weight-bold "+bgc,dvStyle);divFault.innerHTML=pointControlFaultStatus(employee.faultstatus).toString().substr(0,10);cellFaultX.appendChild(divFault);var cellDelayX=document.getElementById("rowPoiConActListCellDelay"+currEmployeeId);bgc=(Number(employee.delaytime)<=0)?" color-gray":(employee.delaystatus<=1)?" font-weight-bold background-color-red-accent":(employee.delaystatus==2)?" font-weight-bold background-color-red-primary":" font-weight-bold background-color-red-primary-dark";let divDelay=createElement("div","","text-align-center "+bgc,dvStyle);divDelay.innerHTML=sec2time(Number(employee.delaytime)*60,!0,!1);cellDelayX.appendChild(divDelay);var cellExtraTimeX=document.getElementById("rowPoiConActListCellExtra"+currEmployeeId);bgc=(Number(employee.extratime)<=0)?" color-gray":" font-weight-bold background-color-green-light";let divExtraTime=createElement("div","","row-height-10 text-align-center  "+bgc,dvStyle);divExtraTime.innerHTML=sec2time(Number(employee.extratime)*60,!0,!1);cellExtraTimeX.appendChild(divExtraTime);var cellEditX=document.getElementById("rowPoiConActListCellEdit"+currEmployeeId);let divEdit=createElement("div","","row-height-10 text-align-center");cellEditX.appendChild(divEdit);let btEdit=document.createElement("button");btEdit.setAttribute("class","labelEdit");btEdit.type="button";btEdit.onclick=function(){setSelectedRowOnClick(document.getElementById("rowPoiConPoiList"+currEmployeeId),"SELECTED_ROW_POINT_CONTROL_POINT_LIST");pointControlPointRegister(employee)};divEdit.appendChild(btEdit);let btInfo=document.createElement("button");btInfo.innerHTML="Registos";btInfo.type="button";btInfo.onclick=function(){setSelectedRowOnClick(document.getElementById("rowPoiConPoiList"+currEmployeeId),"SELECTED_ROW_POINT_CONTROL_POINT_LIST");pointControlEmployeeActivit(employee)};divEdit.appendChild(btInfo)}
if(response.length>=FILTER.pageItems){let newRowC=tableRef.insertRow(-1);newRowC.id="rowPoiConGenAddMore";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(){pointControlPointList(employeeId,FILTER.startIdx+FILTER.pageItems)}}
hideNotification()}
result()}};http.send(params)}
function pointControlPointSynchToActivity(employeeId=-1,attendenceAll=1){if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();FILTER.dependencyId=getElementValue("selPoiConPoiListDependency");FILTER.userId=SYSTEM_USER_STATUS.userId;FILTER.employeeId=employeeId;FILTER.attendenceAll=attendenceAll;FILTER.initialDate=getElementValue('txtPoiConPoiListInitialDate');FILTER.endDate=getElementValue('txtPoiConPoiListEndDate');FILTER.sex="";FILTER.workscheduleId=getElementValue('selPoiConPoiListWorkschedule');FILTER.departmentId=getElementValue("selPoiConPoiListDepartment");FILTER.categoryId=getElementValue("selPoiConPoiListEmployeeCategory");if(ST_SRH_WAITING_SERVER==1){showNotification("Aguardando resposta do servidor. <br>");return!1}
showNotification();ST_SRH_WAITING_SERVER=1;var http=new XMLHttpRequest();var params="action=saveWorkschedulePointSynchActivity"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_WORKSCHEDULE_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);if(response.status==1){alert(response.msg);hideNotification();pointControlPointList(-1,0,1)}else{showNotification(response.msg,0)}}};http.send(params)}
function pointControlPointRegister(point){var wdStatus=Number(point['workdaystatus']);if(wdStatus>2){showNotification("Não pode alterar dados para dia de dispensa ou féria.",0);return!1}else if(wdStatus==2){if(point['workonholiday']==0){showNotification("Não pode alterar dados para dia de feriado ou ponte.",0);return!1}}
var faultStatus=Number(point['faultstatus']);hideParts("btPoiConPoinFault");hideParts("btPoiConPoinFaultJustify");hideParts("btPoiConPoinFaultCancel");hideParts("btPoiConPoinDelayJustify");hideParts("btPoiConPoinDelayCancel");disabledElement("txtPoiConPoiRegStartTime");disabledElement("txtPoiConPoiRegEndTime");disabledElement("txtPoiConPoiRegDelayTime");disabledElement("txtPoiConPoiRegExtraTime");disabledElement("txtPoiConPoiRegFaultStatusReason");disabledElement("txtPoiConPoiRegDelayStatusReason");if(faultStatus<=0){showParts("btPoiConPoinFault",!0);enabledElement("txtPoiConPoiRegStartTime");enabledElement("txtPoiConPoiRegEndTime");enabledElement("txtPoiConPoiRegDelayTime");enabledElement("txtPoiConPoiRegExtraTime");if(Number(point['delaytime'])>=0){var delayStatus=Number(point['delaystatus']);if(delayStatus<=1){showParts("btPoiConPoinDelayJustify",!0);showParts("btPoiConPoinDelayCancel",!0);enabledElement("txtPoiConPoiRegDelayStatusReason")}else if(delayStatus==2){showParts("btPoiConPoinDelayCancel",!0);enabledElement("txtPoiConPoiRegDelayStatusReason")}}}else if(faultStatus==1){showParts("btPoiConPoinFaultJustify",!0);showParts("btPoiConPoinFaultCancel",!0);enabledElement("txtPoiConPoiRegFaultStatusReason")}else if(faultStatus==2){showParts("btPoiConPoinFaultCancel",!0);enabledElement("txtPoiConPoiRegFaultStatusReason")}
showParts("divPointControlPointRegister");setElementInnerHtml("lbPoiConPoiRegWorkscheduleTimeId",point['workscheduletimeid']);setElementInnerHtml("lbPoiConPoiRegEmployeeId",point['employeeid']);setElementInnerHtml("txtPoiConPoiRegEmployeeName",point['employeename']);setElementInnerHtml("lbPoiConPoiRegWorkDay",setLocalDate(point['workday'],10));setElementInnerHtml("lbPoiConPoiRegWorkDayStatus",pointControlWorkDayStatus(point['workdaystatus']));setElementInnerHtml("lbPoiConPoiRegStartTimePlan",setLocalDate(point['starttimeplanned'],16).slice(11));setElementInnerHtml("lbPoiConPoiRegStartTolerance",point['starttolerance']);setElementValue("txtPoiConPoiRegStartTime",point['starttime']);setElementInnerHtml("lbPoiConPoiRegEndTimePlan",setLocalDate(point['endtimeplanned'],16).slice(11));setElementInnerHtml("lbPoiConPoiRegEndTolerance",point['endtolerance']);setElementValue("txtPoiConPoiRegEndTime",point['endtime']);setElementInnerHtml("lbPoiConPoiRegFault",pointControlFaultStatus(point['faultstatus']));setElementValue("txtPoiConPoiRegFaultStatusReason",point['faultstatusreason']);setElementInnerHtml("lbPoiConPoiRegPhotoOld",point['faultstatusphoto']);setElementInnerHtml("aPoiConPoiRegPhoto",point['faultstatusphoto']);setElementAttribute("aPoiConPoiRegPhoto","href",point['photo']);setElementInnerHtml("lbPoiConPoiRegDelayStatus",pointControlDelayStatus(point['delaystatus']));setElementValue("txtPoiConPoiRegDelayStatusReason",point['delaystatusreason']);setElementValue("txtPoiConPoiRegDelayTime",sec2time(Number(point['delaytime'])*60,!0,!1));setElementValue("txtPoiConPoiRegExtraTime",sec2time(Number(point['faultstatusreason'])*60,!0,!1));setElementInnerHtml("lbPoiConPoiRegUpdate","Cadastrado por "+getOperatorName(point['operatorEntry'],point['entryuser'])+" em "+setLocalDate(point['entrydate'],16)+". <br>"+"Actualizado por "+getOperatorName(point['operatorName'],point['statususer'])+" em "+setLocalDate(point['statusdate'],16));var iFrameUp=document.getElementById("iframePoiConPoiRegUploadJustify");iFrameUp.src+="&a"+randomString(3)+"="+randomString(3)}
function pointControlPointRegisterSave(faultstatus,delaystatus=-1){if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();FILTER.employeeid=getElementInnerHTML("lbPoiConPoiRegEmployeeId");FILTER.workscheduletimeid=getElementInnerHTML("lbPoiConPoiRegWorkscheduleTimeId");FILTER.workday=getElementInnerHTML("lbPoiConPoiRegWorkDay");FILTER.starttimeplanned=getElementInnerHTML("lbPoiConPoiRegStartTimePlan");FILTER.starttolerance=getElementInnerHTML("lbPoiConPoiRegStartTolerance");FILTER.starttime=getElementValue("txtPoiConPoiRegStartTime");FILTER.endtimeplanned=getElementInnerHTML("lbPoiConPoiRegEndTimePlan");FILTER.endtolerance=getElementInnerHTML("lbPoiConPoiRegEndTolerance");FILTER.endtime=getElementValue("txtPoiConPoiRegEndTime");FILTER.delaytime=getElementValue("txtPoiConPoiRegDelayTime").toString().split(":");FILTER.faultstatus=faultstatus;FILTER.faultstatusreason=reviewString(document.getElementById("txtPoiConPoiRegFaultStatusReason")).toUpperCase();FILTER.faultstatusphotoOld=getElementInnerHTML("lbPoiConPoiRegPhotoOld");FILTER.faultstatusphoto=getElementInnerHTML("aPoiConPoiRegPhoto");FILTER.delaystatus=delaystatus;FILTER.delaystatusreason=reviewString(document.getElementById("txtPoiConPoiRegDelayStatusReason")).toUpperCase();FILTER.extratime=getElementValue("txtPoiConPoiRegExtraTime").toString().split(":");FILTER.delaytime=(Number(FILTER.delaytime[0])*60)+Number(FILTER.delaytime[1]);FILTER.extratime=(Number(FILTER.extratime[0])*60)+Number(FILTER.extratime[1]);var mandatoryField=!1;var msg="";if(FILTER.faultstatus==1){if((FILTER.starttime!="")||(FILTER.endtime!="")){mandatoryField=!0;msg+="Não pode marcar falta quando foi registada a entrada ou a saída. <br>"}}else if((FILTER.faultstatus==2)||(FILTER.faultstatus==3)){if(FILTER.faultstatusreason==""){mandatoryField=!0;msg+="Deve indicar o motivo da justificação ou anulação da falta. <br>"}}
if(FILTER.delaystatus!=-1){if(FILTER.delaystatusreason==""){mandatoryField=!0;msg+="Deve indicar o motivo da justificação ou anulação do atraso. <br>"}}
if(mandatoryField){alert(msg);return!1}
showNotification();ST_SRH_WAITING_SERVER=1;var http=new XMLHttpRequest();var params="action=saveWorkschedulePointStatus"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_WORKSCHEDULE_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==1){showNotification(result.msg,1);hideParts("divPointControlPointRegister");if(ST_SRH_MAIN_WHO_CALL=="POICONPOILIS"){pointControlPointList(-1,0,1)}}else{showNotification(result.msg,0)}}};http.send(params)}
function pointControlPointReceiveMessage(event){var response=event.data;if(response.status==1){showNotification(response.msg,1);if(response.wc=="POICONPOIREG"){setElementInnerHtml("aPoiConPoiRegPhoto",response.tempfile);var aPhoto=document.getElementById("aPoiConPoiRegPhoto");aPhoto.href=URL_SRH_TEMP_FILE_X+response.tempfile}}else{showNotification(response.msg,0)}}
function pointControlFaultReportOnLoad(){showNotification();setPageTitleWhoCall("4105","POICONFAUREP","Relatório de faltas");function cdoLoad(){fillSelectDependencyFull("selPoiConFauRepDependency",-1,1);fillSelectSex("selPoiConFauRepSex",-1);fillSelectCountry("selPoiConFauRepCountry",-1);fillSelectDepartment("selPoiConFauRepDepartment",-1);fillSelectEmployeeCategory("selPoiConFauRepEmployeeCategory",-1);var date=new Date();setElementValue("txtPoiConFauRepInitialDate",setLocalDate(new Date(date.getFullYear(),date.getMonth(),1),10));setElementValue("txtPoiConFauRepEndDate",setLocalDate(new Date(),10));setTriggerButtonByText('txtPoiConFauRepInitialDate','btPoiConFauRepViewAll');setTriggerButtonByText('txtPoiConFauRepEndDate','btPoiConFauRepViewAll');employeeSearchOnLoad();hideNotification()}
checkUserStatusAfterExecute(cdoLoad)}
function pointControlFaultReportList(employeeId=-1,startIdx=0){if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();FILTER.dependencyId=getElementValue("selPoiConFauRepDependency");FILTER.employeeId=employeeId;FILTER.initialDate=getElementValue('txtPoiConFauRepInitialDate');FILTER.endDate=getElementValue('txtPoiConFauRepEndDate');FILTER.sex=getElementValue('selPoiConFauRepSex');FILTER.nationality=getElementValue('selPoiConFauRepCountry');FILTER.departmentId=getElementValue("selPoiConFauRepDepartment");FILTER.categoryId=getElementValue("selPoiConFauRepEmployeeCategory");FILTER.startIdx=startIdx;if(ST_SRH_WAITING_SERVER==1){showNotification("Aguardando resposta do servidor. <br>");return!1}
let tableRef=document.getElementById("tblPoiConFauRepMainTable");if(FILTER.startIdx==0){tableRef.innerHTML=""}else{removeElement("rowPoiConFauRepAddMore")}
showNotification();ST_SRH_WAITING_SERVER=1;var http=new XMLHttpRequest();var params="action=getPointControlFaultReportList"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_POINT_CONTROL_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","rowPoiConActList"+employee.id);newRow.setAttribute("class","borderGray"+setSelectedRowBackground("SELECTED_ROW_POINT_CONTROL_ACTIVITY_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,"headcol","Nome completo");let cellCategory=createTableCell(newRow,employee.category,"text-align-center font-size-small","Categoria / função");let cellDepart=createTableCell(newRow,employee.department,"text-align-center font-size-small","Posto de trabalho");var color=(employee.fault==0)?" color-gray":"";let cellFault=createTableCell(newRow,employee.fault,"text-align-center font-weight-bold colNoWrap"+color,"Faltas marcadas");color=(employee.faultjustify==0)?" color-gray":"";let cellFaultJust=createTableCell(newRow,employee.faultjustify,"text-align-center colNoWrap"+color,"Faltas Justificadas");color=(employee.faultcanceled==0)?" color-gray":"";let cellFaultCanceled=createTableCell(newRow,employee.faultcanceled,"text-align-center colNoWrap"+color,"Faltas Anuladas");let cellFaultCount=createTableCell(newRow,Number(employee.fault)-Number(employee.faultjustify)-Number(employee.faultcanceled),"text-align-center font-weight-bold colNoWrap","Faltas contabilizadas");color=(employee.delaytime==0)?" color-gray":"";let cellDelay=createTableCell(newRow,sec2time(Number(employee.delaytime*60),!0,!1),"text-align-center colNoWrap"+color,"Atraso");color=(employee.delayjustify==0)?" color-gray":"";let cellDelayJust=createTableCell(newRow,sec2time(Number(employee.delayjustify*60),!0,!1),"text-align-center colNoWrap"+color,"Atraso justificado");color=(employee.delaycancel==0)?" color-gray":"";let cellDelayCanc=createTableCell(newRow,sec2time(Number(employee.delaycancel*60),!0,!1),"text-align-center colNoWrap"+color,"Atraso anulado");color=(employee.delaytime==0)?" color-gray":"";var delay=Number(employee.delaytime)-Number(employee.delayjustify)-Number(employee.delaycancel);let cellDelayCount=createTableCell(newRow,sec2time(Number(delay*60),!0,!1),"text-align-center font-weight-bold colNoWrap"+color,"Atraso contabilizado");var tmp45=0;if(Number(employee.fault)<=0){if(delay>0){tmp45=delay/45}}
let cellTemp45=createTableCell(newRow,formatNumber(tmp45),"text-align-center font-weight-bold colNoWrap"+color,"Tempo 45min contabilizado")}
if(response.length>=FILTER.pageItems){let newRowC=tableRef.insertRow(-1);newRowC.id="rowPoiConFauRepAddMore";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(){pointControlFaultReportList(employeeId,FILTER.startIdx+FILTER.pageItems)}}
hideNotification()}
result()}};http.send(params)}
function pointControlExtraTimeReportOnLoad(){setPageTitleWhoCall("4105","POICONEXTTIMEREP","Relatório de horas extraordinárias");function cdoLoad(){fillSelectSex("selPoiConExtTimeRepSex",-1);fillSelectCountry("selPoiConExtTimeRepCountry",-1);fillSelectDepartment("selPoiConExtTimeRepDepartment",-1);fillSelectEmployeeCategory("selPoiConExtTimeRepEmployeeCategory",-1);var date=new Date();setElementValue("txtPoiConExtTimeRepInitialDate",setLocalDate(new Date(date.getFullYear(),date.getMonth(),1),10));setElementValue("txtPoiConExtTimeRepEndDate",setLocalDate(new Date(),10));setTriggerButtonByText('txtPoiConExtTimeRepInitialDate','btPoiConExtTimeRepViewAll');setTriggerButtonByText('txtPoiConExtTimeRepEndDate','btPoiConExtTimeRepViewAll');pointControlExtraTimeReportList();employeeSearchOnLoad();hideNotification()}
checkUserStatusAfterExecute(cdoLoad)}
function pointControlExtraTimeReportList(employeeId=-1){if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();FILTER.employeeId=employeeId;FILTER.initialDate=getElementValue('txtPoiConExtTimeRepInitialDate');FILTER.endDate=getElementValue('txtPoiConExtTimeRepEndDate');FILTER.sex=getElementValue('selPoiConExtTimeRepSex');FILTER.nationality=getElementValue('selPoiConExtTimeRepCountry');FILTER.departmentId=getElementValue("selPoiConExtTimeRepDepartment");FILTER.categoryId=getElementValue("selPoiConExtTimeRepEmployeeCategory");if(ST_SRH_WAITING_SERVER==1){showNotification("Aguardando resposta do servidor. <br>");return!1}
showNotification();ST_SRH_WAITING_SERVER=1;var http=new XMLHttpRequest();var params="action=getPointControlExtraTimeReportList"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_POINT_CONTROL_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){showNotification('Não foram encontrados trabalhadores para esta folha de salário.',0)}else{hideDivFilter()}
var numPagNumber=document.getElementById("numResultPageNumber");var numItems=document.getElementById("numResultItems");numPagNumber.value=1;setResultTotalPages(numPagNumber.id,numItems.id,totalItems,result);function result(){var pageNumber=Number(numPagNumber.value);var items=Number(numItems.value);var startIdx=(pageNumber-1)*items;var endIdx=startIdx+items;if(endIdx>totalItems){endIdx=totalItems}
setElementInnerHtml('lbResultOnList',endIdx+" / "+totalItems);let tableRef=document.getElementById("tblPoiConExtTimeRepMainTable");tableRef.innerHTML="";var nRows=startIdx;for(var i=startIdx;i<endIdx;i++){let employee=JSON.parse(response[i]);nRows+=1;let newRow=tableRef.insertRow(-1);newRow.setAttribute("id","rowPoiConActList"+employee.id);newRow.setAttribute("class","borderGray"+setSelectedRowBackground("SELECTED_ROW_POINT_CONTROL_ACTIVITY_LIST",newRow.id));let cellRow=createTableCell(newRow,nRows,"colRowNumber","#");let cellId=createTableCell(newRow,employee.employeeid,"colProductId","Código");let cellName=createTableCell(newRow,employee.employeename,"","Nome completo");let cellCategory=createTableCell(newRow,employee.category,"text-align-center font-size-small","Categoria / função");let cellDepart=createTableCell(newRow,employee.department,"text-align-center font-size-small","Posto de trabalho");var color=(employee.extratime==0)?" color-gray":"";let cellDelay=createTableCell(newRow,sec2time(Number(employee.extratime*60),!0,!1),"text-align-center colNoWrap"+color,"Horas extras")}
hideNotification()}
result()}};http.send(params)}
function pointControlActivityDeleteAll(){function realDelete(){if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();FILTER.dependencyId=getElementValue("selPoiConActListDependency");FILTER.initialDate=getElementValue('txtPoiConActListInitialDate');FILTER.endDate=getElementValue('txtPoiConActListEndDate');FILTER.biometricId=getElementValue('selPoiConActListBiometric');if(FILTER.biometricId==-1){alert("Deve seleccionar um dispositivo biométrico");return!1}
if(ST_SRH_WAITING_SERVER==1){showNotification("Aguardando resposta do servidor. <br>");return!1}
showNotification();ST_SRH_WAITING_SERVER=1;var http=new XMLHttpRequest();var params="action=deletePointControlActivityAll"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_POINT_CONTROL_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);if(response.status==1){showNotification(response.msg,1);pointControlActivityList()}else{showNotification(response.msg,0)}}};http.send(params)}
showConfirm("Tem a certeza que deseja apagar estes registos?",realDelete)}
function pointControlEmployeeActivit(employee){showParts("divPointControlEmployeeActivity");setElementInnerHtml("lbPoiConEmpActEmployeeName",employee.employeename);setElementInnerHtml("lbPoiConEmpActStartDate",setLocalDate(employee.workday,10));if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();FILTER.dependencyId=getElementValue("selPoiConPoiListDependency");FILTER.userId=SYSTEM_USER_STATUS.userId;FILTER.employeeId=employee.employeeid;FILTER.initialDate=setLocalDate(employee.workday,10);FILTER.endDate=setLocalDate(employee.workday,10);FILTER.sex="";FILTER.biometricId=-1;FILTER.workscheduleId=-1;FILTER.departmentId=-1;FILTER.categoryId=-1;FILTER.viewMode=2;showNotification();var http=new XMLHttpRequest();var params="action=getPointControlActivityList"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_POINT_CONTROL_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);let tableRef=document.getElementById("tblPoiConEmpActPreviewTable");tableRef.innerHTML="";var nRows=0;for(var i=0;i<response.length;i++){let employee=JSON.parse(response[i]);nRows+=1;let newRow=tableRef.insertRow(-1);newRow.setAttribute("class","borderGray");let cellRowN=createTableCell(newRow,nRows,"colRowNumber","#");let cellDate=createTableCell(newRow,setLocalDate(employee.registertime,10),"text-align-center colNoWrap","Data");let cellTime=createTableCell(newRow,setLocalDate(employee.registertime,16).slice(11),"text-align-center colNoWrap","Hora")}
hideNotification()}};http.send(params)}
function pointControlAttendanceReportOnLoad(){setPageTitleWhoCall("4105","POICONATTREP","Relatório de presenças");function cdoLoad(){fillSelectDependencyFull("selPoiConAttRepDependency",-1,1);fillSelectSex("selPoiConAttRepSex",-1);fillSelectCountry("selPoiConAttRepCountry",-1);fillSelectDepartment("selPoiConAttRepDepartment",-1);fillSelectEmployeeCategory("selPoiConAttRepEmployeeCategory",-1);var date=new Date();setElementValue("txtPoiConAttRepInitialDate",setLocalDate(new Date(date.getFullYear(),date.getMonth(),1),10));setElementValue("txtPoiConAttRepEndDate",setLocalDate(new Date(),10));setTriggerButtonByText('txtPoiConAttRepInitialDate','btPoiConAttRepViewAll');setTriggerButtonByText('txtPoiConAttRepEndDate','btPoiConAttRepViewAll');employeeSearchOnLoad();hideNotification()}
checkUserStatusAfterExecute(cdoLoad)}
function pointControlAttendanceReportList(employeeId=-1,startIdx=0){if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();FILTER.dependencyId=getElementValue("selPoiConAttRepDependency");FILTER.employeeId=employeeId;FILTER.initialDate=getElementValue('txtPoiConAttRepInitialDate');FILTER.endDate=getElementValue('txtPoiConAttRepEndDate');FILTER.sex=getElementValue('selPoiConAttRepSex');FILTER.nationality=getElementValue('selPoiConAttRepCountry');FILTER.departmentId=getElementValue("selPoiConAttRepDepartment");FILTER.categoryId=getElementValue("selPoiConAttRepEmployeeCategory");FILTER.startIdx=startIdx;if(ST_SRH_WAITING_SERVER==1){showNotification("Aguardando resposta do servidor. <br>");return!1}
var tableRef=document.getElementById("tblPoiConAttRepMainTable");if(FILTER.startIdx==0){tableRef.innerHTML=""}else{removeElement("rowPoiConAttRepAddMore")}
showNotification();ST_SRH_WAITING_SERVER=1;var http=new XMLHttpRequest();var params="action=getPointControlAttendanceReportList"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_POINT_CONTROL_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","rowPoiConActList"+employee.id);newRow.setAttribute("class","borderGray"+setSelectedRowBackground("SELECTED_ROW_POINT_CONTROL_ACTIVITY_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,"headcol","Nome completo");let cellCategory=createTableCell(newRow,employee.category,"text-align-center font-size-small","Categoria / função");let cellDepart=createTableCell(newRow,employee.department,"text-align-center font-size-small","Posto de trabalho");var color=(employee.days==0)?" color-gray":"";let cellDays=createTableCell(newRow,employee.days,"text-align-center font-weight-bold colNoWrap"+color,"Presenças (dias)");color=(employee.points==0)?" color-gray":"";let cellPoints=createTableCell(newRow,employee.points,"text-align-center font-weight-bold colNoWrap"+color,"Presenças (turnos)");color=(employee.workduration==0)?" color-gray":"";let cellDuration=createTableCell(newRow,sec2time(Number(employee.workduration*60),!0,!1),"text-align-center font-weight-bold colNoWrap"+color,"Tempo de presença (HH:MM)");let cellTemp45=createTableCell(newRow,formatNumber(Number(employee.workduration)/45),"text-align-center font-weight-bold colNoWrap"+color,"Tempo de presença (45min)")}
if(response.length>=FILTER.pageItems){let newRowC=tableRef.insertRow(-1);newRowC.id="rowPoiConAttRepAddMore";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(){pointControlAttendanceReportList(employeeId,FILTER.startIdx+FILTER.pageItems)}}
hideNotification()}
result()}};http.send(params)}
function pointControlSingleReportOnLoad(){showNotification();setPageTitleWhoCall("4105","POICONSINREP","Relatório Individual");function cdoLoad(){var date=new Date();setElementValue("txtPoiConSinRepInitialDate",setLocalDate(new Date(date.getFullYear(),date.getMonth(),1),10));setElementValue("txtPoiConSinRepEndDate",setLocalDate(new Date(),10));employeeSearchOnLoad();hideNotification()}
checkUserStatusAfterExecute(cdoLoad)}
function pointControlSingleReportList(employee,startIdx=0){if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();FILTER.dependencyId=-1;FILTER.userId=SYSTEM_USER_STATUS.userId;FILTER.employeeId=employee.employeeid;FILTER.initialDate=getElementValue('txtPoiConSinRepInitialDate');FILTER.endDate=getElementValue('txtPoiConSinRepEndDate');FILTER.sex="";FILTER.workscheduleId=-1;FILTER.departmentId=-1;FILTER.categoryId=-1;FILTER.viewMode=2;FILTER.startIdx=startIdx;if(ST_SRH_WAITING_SERVER==1){showNotification("Aguardando resposta do servidor. <br>");return!1}
setElementInnerHtml("selPoiConSinRepEmployeeId",employee.employeeid);setElementInnerHtml("selPoiConSinRepAgent",employee.agentnumberreal);setElementInnerHtml("selPoiConSinRepEmployeeName",employee.employeename);var tableRef=document.getElementById("tblPoiConSinRepMainTable");if(FILTER.startIdx==0){tableRef.innerHTML=""}else{removeElement("rowPoiConGenAddMore")}
showNotification();ST_SRH_WAITING_SERVER=1;var http=new XMLHttpRequest();var params="action=getWorkschedulePointList"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_WORKSCHEDULE_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]);let currEmployeeId=employee.employeeid+"_"+setLocalDate(employee.workday,10).toString().replace("-","");nRows+=1;let newRow=tableRef.insertRow(-1);newRow.setAttribute("id","rowPoiConPoiList"+currEmployeeId);newRow.setAttribute("class","borderGray"+setSelectedRowBackground("SELECTED_ROW_POINT_CONTROL_SINGLE_REPORT",newRow.id));let cellRow=createTableCell(newRow,nRows,"colRowNumber","#");cellRow.setAttribute("id","rowPoiConActListCellRow"+currEmployeeId);var currWorkDay=weekDay(new Date(employee.workday).getDay(),1)+", "+setLocalDate(employee.workday,10)+employee.teachingperiodtime;let cellDay=createTableCell(newRow,currWorkDay,"colNoWrap font-weight-bold","Dia");let cellDesc=createTableCell(newRow,employee.description.toString().replace("*","<br>"),"","Descrição");cellDesc.setAttribute("id","rowPoiConActListCellDescription"+currEmployeeId);let cellStatus=createTableCell(newRow,"","","Estado");cellStatus.setAttribute("id","rowPoiConActListCellStatus"+currEmployeeId);let cellStartPlan=createTableCell(newRow,"","","Entrada prevista");cellStartPlan.setAttribute("id","rowPoiConActListCellSyartPla"+currEmployeeId);let cellStartReg=createTableCell(newRow,"","","Entrada registada");cellStartReg.setAttribute("id","rowPoiConActListCellStartReg"+currEmployeeId);let cellEndPlan=createTableCell(newRow,"","","Saída prevista");cellEndPlan.setAttribute("id","rowPoiConActListCellEndPlan"+currEmployeeId);let cellEndReg=createTableCell(newRow,"","","Saída registada");cellEndReg.setAttribute("id","rowPoiConActListCellEndReg"+currEmployeeId);let cellWorkTime=createTableCell(newRow,"","","Tempo de trabalho");cellWorkTime.setAttribute("id","rowPoiConActListCellWorkTime"+currEmployeeId);let cellFault=createTableCell(newRow,"","","Falta");cellFault.setAttribute("id","rowPoiConActListCellFault"+currEmployeeId);let cellDelay=createTableCell(newRow,"","","Tempo de atraso");cellDelay.setAttribute("id","rowPoiConActListCellDelay"+currEmployeeId);var dvStyle="";var bgc=(employee.workdaystatus==2)?" background-color-brown":"";let divStatus=createElement("div","","row-height-10 text-align-center colNoWrap"+bgc,dvStyle);divStatus.innerHTML=pointControlWorkDayStatus(employee.workdaystatus);cellStatus.appendChild(divStatus);let divStartPlan=createElement("div","","row-height-10 text-align-center color-gray",dvStyle);divStartPlan.innerHTML=setLocalDate(employee.starttimeplanned,16).slice(11);cellStartPlan.appendChild(divStartPlan);let divStartReg=createElement("div","","row-height-10 text-align-center font-weight-bold",dvStyle);divStartReg.innerHTML=employee.starttime;cellStartReg.appendChild(divStartReg);let divEndPlan=createElement("div","","row-height-10 text-align-center color-gray",dvStyle);divEndPlan.innerHTML=setLocalDate(employee.endtimeplanned,16).slice(11);cellEndPlan.appendChild(divEndPlan);let divEndReg=createElement("div","","row-height-10 text-align-center font-weight-bold",dvStyle);divEndReg.innerHTML=employee.endtime;cellEndReg.appendChild(divEndReg);let divWorkTime=createElement("div","","row-height-10 text-align-center  color-gray",dvStyle);divWorkTime.innerHTML=sec2time(Number(employee.workduration)*60,!0,!1);cellWorkTime.appendChild(divWorkTime);bgc=(Number(employee.faultstatus)<1)?"":(employee.faultstatus==1)?" background-color-red-accent":(employee.faultstatus==2)?" background-color-red-primary":" background-color-red-primary-dark";let divFault=createElement("div","","row-height-10 colNoWrap text-align-center font-weight-bold "+bgc,dvStyle);divFault.innerHTML=pointControlFaultStatus(employee.faultstatus).toString().substr(0,10);cellFault.appendChild(divFault);bgc=(Number(employee.delaytime)<=0)?" color-gray":(employee.delaystatus<=1)?" font-weight-bold background-color-red-accent":(employee.delaystatus==2)?" font-weight-bold background-color-red-primary":" font-weight-bold background-color-red-primary-dark";let divDelay=createElement("div","","text-align-center "+bgc,dvStyle);divDelay.innerHTML=sec2time(Number(employee.delaytime)*60,!0,!1);cellDelay.appendChild(divDelay)}
if(response.length>=FILTER.pageItems){let newRowC=tableRef.insertRow(-1);newRowC.id="rowPoiConGenAddMore";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(){pointControlSingleReportList(employee,FILTER.startIdx+FILTER.pageItems)}}
hideNotification()}
result()}};http.send(params)}
function myPointControlActivityList(startIdx=0){if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();FILTER.dependencyId=-1;FILTER.employeeId=SYSTEM_USER_STATUS.employeeId;FILTER.initialDate=getElementValue('txtPoiConActListInitialDate');FILTER.endDate=getElementValue('txtPoiConActListEndDate');FILTER.biometricId=-1;FILTER.workscheduleId=-1;FILTER.departmentId=-1;FILTER.categoryId=-1;FILTER.viewMode=1;FILTER.startIdx=startIdx;if(ST_SRH_WAITING_SERVER==1){showNotification("Aguardando resposta do servidor. <br>");return!1}
let tableRef=document.getElementById("tblPoiConActListMainTable");if(FILTER.startIdx==0){tableRef.innerHTML=""}else{removeElement("rowPoiConActAddMore")}
showNotification();ST_SRH_WAITING_SERVER=1;var http=new XMLHttpRequest();var params="action=getPointControlActivityList"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_POINT_CONTROL_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+totalItems);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","rowPoiConActList"+employee.id);newRow.setAttribute("class","borderGray"+setSelectedRowBackground("SELECTED_ROW_POINT_CONTROL_ACTIVITY_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,"headcol","Nome completo");let cellDate=createTableCell(newRow,setLocalDate(employee.registertime,10),"text-align-center colNoWrap","Data");let cellTime=createTableCell(newRow,setLocalDate(employee.registertime,16).slice(11),"text-align-center colNoWrap","Hora");let cellBio=createTableCell(newRow,employee.brand,"text-align-center","Dispositivo biométrico");let cellIdentif=createTableCell(newRow,employee.biometricidentification,"text-align-center","Identificador Único");let cellWorkSche=createTableCell(newRow,employee.workschedule,"text-align-center font-size-small","Turno");let cellCategory=createTableCell(newRow,employee.category,"text-align-center font-size-small","Categoria / função");let cellDepart=createTableCell(newRow,employee.department,"text-align-center font-size-small","Posto de trabalho")}
if(response.length>=FILTER.pageItems){let newRowC=tableRef.insertRow(-1);newRowC.id="rowPoiConActAddMore";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(){myPointControlActivityList(FILTER.startIdx+FILTER.pageItems)}}
hideNotification()}
result()}};http.send(params)}
function myPointControlActivityOnLoad(){showNotification();setPageTitleWhoCall("0000","POICONACTLIS","Minhas actividade no biométrico");function cdoLoad(){var date=new Date();setElementValue("txtPoiConActListInitialDate",setLocalDate(new Date(date.getFullYear(),date.getMonth(),1),10));setElementValue("txtPoiConActListEndDate",setLocalDate(new Date(),10));setTriggerButtonByText('txtPoiConActListInitialDate','btPoiConActListViewAll');setTriggerButtonByText('txtPoiConActListEndDate','btPoiConActListViewAll');hideNotification()}
checkUserStatusAfterExecute(cdoLoad)}
function myPointControlAttendanceReportOnLoad(){setPageTitleWhoCall("0000","POICONATTREP","Meu relatório de presenças");function cdoLoad(){var date=new Date();setElementValue("txtPoiConAttRepInitialDate",setLocalDate(new Date(date.getFullYear(),date.getMonth(),1),10));setElementValue("txtPoiConAttRepEndDate",setLocalDate(new Date(),10));setTriggerButtonByText('txtPoiConAttRepInitialDate','btPoiConAttRepViewAll');setTriggerButtonByText('txtPoiConAttRepEndDate','btPoiConAttRepViewAll');myPointControlAttendanceReportList();hideNotification()}
checkUserStatusAfterExecute(cdoLoad)}
function myPointControlAttendanceReportList(startIdx=0){if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();FILTER.dependencyId=-1;FILTER.employeeId=SYSTEM_USER_STATUS.employeeId;FILTER.initialDate=getElementValue('txtPoiConAttRepInitialDate');FILTER.endDate=getElementValue('txtPoiConAttRepEndDate');FILTER.sex="";FILTER.nationality=-1;FILTER.departmentId=-1;FILTER.categoryId=-1;FILTER.startIdx=startIdx;if(ST_SRH_WAITING_SERVER==1){showNotification("Aguardando resposta do servidor. <br>");return!1}
let tableRef=document.getElementById("tblPoiConAttRepMainTable");if(FILTER.startIdx==0){tableRef.innerHTML=""}else{removeElement("rowPoiConAttRepAddMore")}
showNotification();ST_SRH_WAITING_SERVER=1;var http=new XMLHttpRequest();var params="action=getPointControlAttendanceReportList"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_POINT_CONTROL_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","rowPoiConActList"+employee.id);newRow.setAttribute("class","borderGray"+setSelectedRowBackground("SELECTED_ROW_POINT_CONTROL_ACTIVITY_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,"headcol","Nome completo");let cellCategory=createTableCell(newRow,employee.category,"text-align-center font-size-small","Categoria / função");let cellDepart=createTableCell(newRow,employee.department,"text-align-center font-size-small","Posto de trabalho");var color=(employee.days==0)?" color-gray":"";let cellDays=createTableCell(newRow,employee.days,"text-align-center font-weight-bold colNoWrap"+color,"Presenças (dias)");color=(employee.points==0)?" color-gray":"";let cellPoints=createTableCell(newRow,employee.points,"text-align-center font-weight-bold colNoWrap"+color,"Presenças (turnos)");color=(employee.workduration==0)?" color-gray":"";let cellDuration=createTableCell(newRow,sec2time(Number(employee.workduration*60),!0,!1),"text-align-center font-weight-bold colNoWrap"+color,"Tempo de presença (HH:MM)");let cellTemp45=createTableCell(newRow,formatNumber(Number(employee.workduration)/45),"text-align-center font-weight-bold colNoWrap"+color,"Tempo de presença (45min)")}
if(response.length>=FILTER.pageItems){let newRowC=tableRef.insertRow(-1);newRowC.id="rowPoiConAttRepAddMore";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(){myPointControlAttendanceReportList(FILTER.startIdx+FILTER.pageItems)}}
hideNotification()}
result()}};http.send(params)}
function myPointControlFaultReportOnLoad(){showNotification();setPageTitleWhoCall("0000","POICONFAUREP","Meu relatório de faltas");function cdoLoad(){var date=new Date();setElementValue("txtPoiConFauRepInitialDate",setLocalDate(new Date(date.getFullYear(),date.getMonth(),1),10));setElementValue("txtPoiConFauRepEndDate",setLocalDate(new Date(),10));setTriggerButtonByText('txtPoiConFauRepInitialDate','btPoiConFauRepViewAll');setTriggerButtonByText('txtPoiConFauRepEndDate','btPoiConFauRepViewAll');myPointControlFaultReportList();hideNotification()}
checkUserStatusAfterExecute(cdoLoad)}
function myPointControlFaultReportList(startIdx=0){if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();FILTER.dependencyId=-1;FILTER.employeeId=SYSTEM_USER_STATUS.employeeId;FILTER.initialDate=getElementValue('txtPoiConFauRepInitialDate');FILTER.endDate=getElementValue('txtPoiConFauRepEndDate');FILTER.sex=-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>");return!1}
let tableRef=document.getElementById("tblPoiConFauRepMainTable");if(FILTER.startIdx==0){tableRef.innerHTML=""}else{removeElement("rowPoiConFauRepAddMore")}
showNotification();ST_SRH_WAITING_SERVER=1;var http=new XMLHttpRequest();var params="action=getPointControlFaultReportList"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_POINT_CONTROL_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","rowPoiConActList"+employee.id);newRow.setAttribute("class","borderGray"+setSelectedRowBackground("SELECTED_ROW_POINT_CONTROL_ACTIVITY_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,"headcol","Nome completo");let cellCategory=createTableCell(newRow,employee.category,"text-align-center font-size-small","Categoria / função");let cellDepart=createTableCell(newRow,employee.department,"text-align-center font-size-small","Posto de trabalho");var color=(employee.fault==0)?" color-gray":"";let cellFault=createTableCell(newRow,employee.fault,"text-align-center font-weight-bold colNoWrap"+color,"Faltas marcadas");color=(employee.faultjustify==0)?" color-gray":"";let cellFaultJust=createTableCell(newRow,employee.faultjustify,"text-align-center colNoWrap"+color,"Faltas Justificadas");color=(employee.faultcanceled==0)?" color-gray":"";let cellFaultCanceled=createTableCell(newRow,employee.faultcanceled,"text-align-center colNoWrap"+color,"Faltas Anuladas");let cellFaultCount=createTableCell(newRow,Number(employee.fault)-Number(employee.faultjustify)-Number(employee.faultcanceled),"text-align-center font-weight-bold colNoWrap","Faltas contabilizadas");color=(employee.delaytime==0)?" color-gray":"";let cellDelay=createTableCell(newRow,sec2time(Number(employee.delaytime*60),!0,!1),"text-align-center colNoWrap"+color,"Atraso");color=(employee.delayjustify==0)?" color-gray":"";let cellDelayJust=createTableCell(newRow,sec2time(Number(employee.delayjustify*60),!0,!1),"text-align-center colNoWrap"+color,"Atraso justificado");color=(employee.delaycancel==0)?" color-gray":"";let cellDelayCanc=createTableCell(newRow,sec2time(Number(employee.delaycancel*60),!0,!1),"text-align-center colNoWrap"+color,"Atraso anulado");color=(employee.delaytime==0)?" color-gray":"";var delay=Number(employee.delaytime)-Number(employee.delayjustify)-Number(employee.delaycancel);let cellDelayCount=createTableCell(newRow,sec2time(Number(delay*60),!0,!1),"text-align-center font-weight-bold colNoWrap"+color,"Atraso contabilizado");var tmp45=0;if(Number(employee.fault)<=0){if(delay>0){tmp45=delay/45}}
let cellTemp45=createTableCell(newRow,formatNumber(tmp45),"text-align-center font-weight-bold colNoWrap"+color,"Tempo 45min contabilizado")}
if(response.length>=FILTER.pageItems){let newRowC=tableRef.insertRow(-1);newRowC.id="rowPoiConFauRepAddMore";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(){myPointControlFaultReportList(FILTER.startIdx+FILTER.pageItems)}}
hideNotification()}
result()}};http.send(params)}
function myPointControlSingleReportOnLoad(){showNotification();setPageTitleWhoCall("0000","POICONSINREP","Relatório Individual");function cdoLoad(){var date=new Date();setElementValue("txtPoiConSinRepInitialDate",setLocalDate(new Date(date.getFullYear(),date.getMonth(),1),10));setElementValue("txtPoiConSinRepEndDate",setLocalDate(new Date(),10));hideNotification()}
checkUserStatusAfterExecute(cdoLoad)}
function myPointControlSingleReportList(startIdx=0){if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();FILTER.dependencyId=-1;FILTER.userId=SYSTEM_USER_STATUS.userId;FILTER.employeeId=SYSTEM_USER_STATUS.employeeId;FILTER.initialDate=getElementValue('txtPoiConSinRepInitialDate');FILTER.endDate=getElementValue('txtPoiConSinRepEndDate');FILTER.sex="";FILTER.workscheduleId=-1;FILTER.departmentId=-1;FILTER.categoryId=-1;FILTER.viewMode=2;FILTER.startIdx=startIdx;if(ST_SRH_WAITING_SERVER==1){showNotification("Aguardando resposta do servidor. <br>");return!1}
var tableRef=document.getElementById("tblPoiConSinRepMainTable");if(FILTER.startIdx==0){tableRef.innerHTML=""}else{removeElement("rowPoiConGenAddMore")}
showNotification();ST_SRH_WAITING_SERVER=1;var http=new XMLHttpRequest();var params="action=getWorkschedulePointList"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_WORKSCHEDULE_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]);let currEmployeeId=employee.employeeid+"_"+setLocalDate(employee.workday,10).toString().replace("-","");nRows+=1;let newRow=tableRef.insertRow(-1);newRow.setAttribute("id","rowPoiConPoiList"+currEmployeeId);newRow.setAttribute("class","borderGray"+setSelectedRowBackground("SELECTED_ROW_POINT_CONTROL_SINGLE_REPORT",newRow.id));let cellRow=createTableCell(newRow,nRows,"colRowNumber","#");cellRow.setAttribute("id","rowPoiConActListCellRow"+currEmployeeId);var currWorkDay=weekDay(new Date(employee.workday).getDay(),1)+", "+setLocalDate(employee.workday,10)+employee.teachingperiodtime;let cellDay=createTableCell(newRow,currWorkDay,"colNoWrap font-weight-bold","Dia");let cellDesc=createTableCell(newRow,employee.description.toString().replace("*","<br>"),"","Descrição");cellDesc.setAttribute("id","rowPoiConActListCellDescription"+currEmployeeId);let cellStatus=createTableCell(newRow,"","","Estado");cellStatus.setAttribute("id","rowPoiConActListCellStatus"+currEmployeeId);let cellStartPlan=createTableCell(newRow,"","","Entrada prevista");cellStartPlan.setAttribute("id","rowPoiConActListCellSyartPla"+currEmployeeId);let cellStartReg=createTableCell(newRow,"","","Entrada registada");cellStartReg.setAttribute("id","rowPoiConActListCellStartReg"+currEmployeeId);let cellEndPlan=createTableCell(newRow,"","","Saída prevista");cellEndPlan.setAttribute("id","rowPoiConActListCellEndPlan"+currEmployeeId);let cellEndReg=createTableCell(newRow,"","","Saída registada");cellEndReg.setAttribute("id","rowPoiConActListCellEndReg"+currEmployeeId);let cellWorkTime=createTableCell(newRow,"","","Tempo de trabalho");cellWorkTime.setAttribute("id","rowPoiConActListCellWorkTime"+currEmployeeId);let cellFault=createTableCell(newRow,"","","Falta");cellFault.setAttribute("id","rowPoiConActListCellFault"+currEmployeeId);let cellDelay=createTableCell(newRow,"","","Tempo de atraso");cellDelay.setAttribute("id","rowPoiConActListCellDelay"+currEmployeeId);var dvStyle="";var bgc=(employee.workdaystatus==2)?" background-color-brown":"";let divStatus=createElement("div","","row-height-10 text-align-center colNoWrap"+bgc,dvStyle);divStatus.innerHTML=pointControlWorkDayStatus(employee.workdaystatus);cellStatus.appendChild(divStatus);let divStartPlan=createElement("div","","row-height-10 text-align-center color-gray",dvStyle);divStartPlan.innerHTML=setLocalDate(employee.starttimeplanned,16).slice(11);cellStartPlan.appendChild(divStartPlan);let divStartReg=createElement("div","","row-height-10 text-align-center font-weight-bold",dvStyle);divStartReg.innerHTML=employee.starttime;cellStartReg.appendChild(divStartReg);let divEndPlan=createElement("div","","row-height-10 text-align-center color-gray",dvStyle);divEndPlan.innerHTML=setLocalDate(employee.endtimeplanned,16).slice(11);cellEndPlan.appendChild(divEndPlan);let divEndReg=createElement("div","","row-height-10 text-align-center font-weight-bold",dvStyle);divEndReg.innerHTML=employee.endtime;cellEndReg.appendChild(divEndReg);let divWorkTime=createElement("div","","row-height-10 text-align-center  color-gray",dvStyle);divWorkTime.innerHTML=sec2time(Number(employee.workduration)*60,!0,!1);cellWorkTime.appendChild(divWorkTime);bgc=(Number(employee.faultstatus)<1)?"":(employee.faultstatus==1)?" background-color-red-accent":(employee.faultstatus==2)?" background-color-red-primary":" background-color-red-primary-dark";let divFault=createElement("div","","row-height-10 colNoWrap text-align-center font-weight-bold "+bgc,dvStyle);divFault.innerHTML=pointControlFaultStatus(employee.faultstatus).toString().substr(0,10);cellFault.appendChild(divFault);bgc=(Number(employee.delaytime)<=0)?" color-gray":(employee.delaystatus<=1)?" font-weight-bold background-color-red-accent":(employee.delaystatus==2)?" font-weight-bold background-color-red-primary":" font-weight-bold background-color-red-primary-dark";let divDelay=createElement("div","","text-align-center "+bgc,dvStyle);divDelay.innerHTML=sec2time(Number(employee.delaytime)*60,!0,!1);cellDelay.appendChild(divDelay)}
if(response.length>=FILTER.pageItems){let newRowC=tableRef.insertRow(-1);newRowC.id="rowPoiConGenAddMore";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(){myPointControlSingleReportList(FILTER.startIdx+FILTER.pageItems)}}
hideNotification()}
result()}};http.send(params)}
function pointControlPointClearFault(){if(!desktopSecurityCheck()){return!1}
function callback(){var FILTER=setFilterStatus();FILTER.dependencyId=getElementValue("selPoiConPoiListDependency");FILTER.userId=SYSTEM_USER_STATUS.userId;FILTER.initialDate=getElementValue('txtPoiConPoiListInitialDate');FILTER.endDate=getElementValue('txtPoiConPoiListEndDate');FILTER.sex="";FILTER.workscheduleId=getElementValue('selPoiConPoiListWorkschedule');FILTER.departmentId=getElementValue("selPoiConPoiListDepartment");FILTER.categoryId=getElementValue("selPoiConPoiListEmployeeCategory");if(ST_SRH_WAITING_SERVER==1){showNotification("Aguardando resposta do servidor. <br>");return!1}
showNotification();ST_SRH_WAITING_SERVER=1;var http=new XMLHttpRequest();var params="action=saveWorkschedulePointClearFault"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_WORKSCHEDULE_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);if(response.status==1){showNotification(response.msg);hideNotification();pointControlPointList()}else{showNotification(response.msg,0)}}};http.send(params)}
showConfirm("Tem a certeza que deseja apagar as faltas no período indicado?",callback)}