function bankAccountBankOnLoad(){showNotification();setPageTitleWhoCall("1910","COMPACCBAN","Lista contas bancárias")
function baboLoad(){fillSelectDependencyFull('selBanConDependency',-1,1);fillSelectNationalBank('selBanConNationalBank',-1);maskInputByPlaceHold("txtBanConAccountNumber");maskInputByPlaceHold("txtBanConIban");bankAccountBankNew();bankAccountBankList();hideNotification()}
checkUserStatusAfterExecute(baboLoad)}
function bankAccountBankNew(a){showDivFilter();setElementValue("selBanConDependency",SYSTEM_USER_STATUS.workplaceId);document.getElementById('txtBanConAccountId').value='Nova conta';var natBk=document.getElementById('selBanConNationalBank');natBk.value=-1;natBk.disabled="";document.getElementById('txtBanConAgency').value="";document.getElementById('txtBanConAccountNumber').value="";document.getElementById('txtBanConIban').value="";document.getElementById('txtBanConSwift').value="";document.getElementById('selBanConAvailiableOnInvoice').value=1;document.getElementById('txtBanConAccountNumber').focus();dispatchOnInputChange()}
function bankAccountBankList(){showNotification();if(!desktopSecurityCheck()){return!1}
var FILTER=setFilterStatus();FILTER.accountId=-1;if(Number(SYSTEM_USER_STATUS.billingprofile)>=BILLING_PROFILE_DEPARTMENT_BOSS_INDEX){FILTER.dependencyId=-1}
var http=new XMLHttpRequest();var params="action=getBankAccountList"+"&filterInfo="+JSON.stringify(FILTER);var url=URL_SRH_COMPANY_X;http.open('POST',url,!0);http.setRequestHeader('Content-type','application/x-www-form-urlencoded');http.onreadystatechange=function(){if(this.readyState==4&&this.status==200){var accounts=validateSession(http);if(accounts.length<=0){showNotification('Não foram encontradas.',0)}else{hideDivFilter()}
document.getElementById('lbResultOnList').innerHTML=accounts.length;let tableRef=document.getElementById("tblBanConMainTable");tableRef.innerHTML="";var nRows=0;accounts.forEach(element=>createTbl(element));function createTbl(element){nRows+=1;let account=JSON.parse(element);let newRow=tableRef.insertRow(-1);newRow.setAttribute("class","borderGray");let cellRow=createTableCell(newRow,nRows,"colRowNumber","#");let cellCode=createTableCell(newRow,account.accountid,"colProductId","Código");let cellBank=createTableCell(newRow,account.bankname,"","Banco");let cellAccount=createTableCell(newRow,account.accountnumber,"","Conta nº");let cellIban=createTableCell(newRow,account.iban,"","IBAN");let cellDependency=createTableCell(newRow,account.dependency,"","Filial");let cellAvailiable=createTableCell(newRow,"","colSimNao","Disponível na factura");var availiable="Sim";if(account.availiableoninvoice!=1){availiable="Não"}
cellAvailiable.innerHTML=availiable;let cellEdit=createTableCell(newRow,"","noPrint","...");let btEdit=document.createElement("button");btEdit.type="button";btEdit.setAttribute("class","labelEdit");const id=account.id;btEdit.onclick=function(){showDivFilter();bankEditAccountBank(id)};cellEdit.appendChild(btEdit);let btDelete=document.createElement("button");btDelete.setAttribute("class","labelDelete");btDelete.type="button";btDelete.onclick=function(){bankDeleteAccountBank(id)};cellEdit.appendChild(btDelete)}
hideNotification()}};http.send(params)}