/** * Vai buscar os dados do cartão * * @return */ function mnet_getData(formId, img, noCardErrorDiv, wrongCardErrorDiv, isParent, alunoId, eeId) { var result = true; // Aqui verifica sempre se o cartão está presente result = mnet_checkCardPresence(noCardErrorDiv, wrongCardErrorDiv); if (result == false) { return result; } // Se passar verifica se é ecrã de pai/mãe, se for.. if (isParent == true) { result = mnet_checkDataIntegrityForParent(formId, alunoId, eeId, wrongCardErrorDiv, noCardErrorDiv); } if (result == false) { return result; } // se chegar aqui é porque o cartão está presente e é válido nesta situação var nomeProprio = document.getElementById('mnet_appletLeitor') .obterIndividuo().getNomeProprio(); var apelidos = document.getElementById('mnet_appletLeitor') .obterIndividuo().getApelidos(); var bi = document.getElementById('mnet_appletLeitor').obterIndividuo() .getIdentificacaoCivil(); var nif = document.getElementById('mnet_appletLeitor').obterIndividuo() .getNumeroIdentificacaoFiscal(); var utente = document.getElementById('mnet_appletLeitor').obterIndividuo() .getNumeroUtente(); var dataValidade = document.getElementById('mnet_appletLeitor') .obterIndividuo().getDataValidade(); var dataNascimento = document.getElementById('mnet_appletLeitor') .obterIndividuo().getDataNascimento(); var numSS = document.getElementById('mnet_appletLeitor').obterIndividuo() .getNumeroSegurancaSocia(); var sexo = document.getElementById('mnet_appletLeitor').obterIndividuo() .getSexo(); var foto; if (img == 1) { foto = document.getElementById('mnet_appletLeitor').obterIndividuo() .getFotografia(); } setFieldValue(formId, 'mnet_name', nomeProprio); setFieldValue(formId, 'mnet_lastName', apelidos); setFieldValue(formId, 'mnet_numId', bi); setFieldValue(formId, 'mnet_numNif', nif); setFieldValue(formId, 'mnet_numUtente', utente); setFieldValue(formId, 'mnet_dataNascimento', dataNascimento); setFieldValue(formId, 'mnet_dataValidade', dataValidade); setFieldValue(formId, 'mnet_sexo', sexo); setFieldValue(formId, 'mnet_numSS', numSS); if (formId == 'eeForm') { setFieldValue(formId, 'tipoDocumento', 8); } if (img == 1) { setFieldValue(formId, 'mnet_foto', foto); } return result; } function mnet_verificaCartaoPresente(formId) { var result = false; var numeroCartaoPresente = document.getElementById('mnet_appletLeitor') .obterIndividuo().getIdentificacaoCivil(); if (document.getElementById(formId + ':mnet_numeroDocumentoAutenticado') != null) { var numeroCartaoNoForm = document.getElementById(formId + ':mnet_numeroDocumentoAutenticado').value; if (numeroCartaoNoForm == null || numeroCartaoNoForm == "") { result = true; // uma vez que foi a 1ª utilização } else if (numeroCartaoPresente == numeroCartaoNoForm) { result = true; } else if (numeroCartaoPresente != numeroCartaoNoForm) { result = false; } else { result = false; } } return result; } /** * Vai obter os dados livres na applet */ function mnet_loadData() { // Vamos buscar os dados à applet var infoIsHere = document.getElementById('mnet_appletLeitor') .obterDadosLivresCartao(); return infoIsHere; } function mnet_loadAddressData() { var infoIsHere = document.getElementById('mnet_appletLeitor') .obterDadosMorada(); return infoIsHere; } function mnet_getAddressData(formId, noCardErrorDiv, wrongCardInfoDiv) { var id = mnet_loadAddressData(); while (id == null) { } if (id == "-1") { document.getElementById(noCardErrorDiv).style.display = 'block'; if (document.getElementById(wrongCardInfoDiv) != null) { document.getElementById(wrongCardInfoDiv).style.display = 'none'; } return false; } var numId = document.getElementById(formId + ':mnet_numId'); if (numId != null && numId.value != null && numId.value != "" && numId.value != id) { document.getElementById(noCardErrorDiv).style.display = 'none'; document.getElementById(wrongCardInfoDiv).style.display = 'block'; return false; } var moradaConcelho = document.getElementById('mnet_appletLeitor') .obterIndividuo().getMoradaConcelho(); var moradaDistrito = document.getElementById('mnet_appletLeitor') .obterIndividuo().getMoradaDistrito(); var moradaFreguesia = document.getElementById('mnet_appletLeitor') .obterIndividuo().getMoradaFreguesia(); var moradaLocalidade = document.getElementById('mnet_appletLeitor') .obterIndividuo().getMoradaLocalidade(); var moradaNumeroPorta = document.getElementById('mnet_appletLeitor') .obterIndividuo().getMoradaNumeroPorta(); var moradaDesignacaoVia = document.getElementById('mnet_appletLeitor') .obterIndividuo().getMoradaDesignacaoVia(); var moradaLado = document.getElementById('mnet_appletLeitor') .obterIndividuo().getMoradaLado(); var moradaAndar = document.getElementById('mnet_appletLeitor') .obterIndividuo().getMoradaAndar(); var moradaRua = document.getElementById('mnet_appletLeitor') .obterIndividuo().getMoradaRua(); var codigoPostal = document.getElementById('mnet_appletLeitor') .obterIndividuo().getCodigoPostal(); var codigoPostalComplemento = document.getElementById('mnet_appletLeitor') .obterIndividuo().getCodigoPostalComplemento(); var codigoFreguesia = document.getElementById('mnet_appletLeitor') .obterIndividuo().getCodigoFreguesia(); setFieldValue(formId, 'mnet_moradaLocalidade', moradaLocalidade); setFieldValue(formId, 'mnet_codigoPostal', codigoPostal); setFieldValue(formId, 'mnet_codigoPostalComplemento', codigoPostalComplemento); setFieldValue(formId, 'mnet_codigoFreguesiaFromCc', codigoFreguesia); setFieldValue(formId, 'mnet_mdcAndar', moradaAndar + " " + moradaLado); setFieldValue(formId, 'mnet_mdcMorada', moradaDesignacaoVia + " " + moradaRua); setFieldValue(formId, 'mnet_mdcPorta', moradaNumeroPorta); return true; } function mnet_getAddressDataNoAuthenticationRequired(formId, noCardErrorDiv) { var id = mnet_loadAddressData(); while (id == null) { } if (id == "-1") { document.getElementById(noCardErrorDiv).style.display = 'block'; return false; } var moradaConcelho = document.getElementById('mnet_appletLeitor') .obterIndividuo().getMoradaConcelho(); var moradaDistrito = document.getElementById('mnet_appletLeitor') .obterIndividuo().getMoradaDistrito(); var moradaFreguesia = document.getElementById('mnet_appletLeitor') .obterIndividuo().getMoradaFreguesia(); var moradaLocalidade = document.getElementById('mnet_appletLeitor') .obterIndividuo().getMoradaLocalidade(); var moradaNumeroPorta = document.getElementById('mnet_appletLeitor') .obterIndividuo().getMoradaNumeroPorta(); var moradaDesignacaoVia = document.getElementById('mnet_appletLeitor') .obterIndividuo().getMoradaDesignacaoVia(); var moradaLado = document.getElementById('mnet_appletLeitor') .obterIndividuo().getMoradaLado(); var moradaAndar = document.getElementById('mnet_appletLeitor') .obterIndividuo().getMoradaAndar(); var moradaRua = document.getElementById('mnet_appletLeitor') .obterIndividuo().getMoradaRua(); var codigoPostal = document.getElementById('mnet_appletLeitor') .obterIndividuo().getCodigoPostal(); var codigoPostalComplemento = document.getElementById('mnet_appletLeitor') .obterIndividuo().getCodigoPostalComplemento(); var codigoFreguesia = document.getElementById('mnet_appletLeitor') .obterIndividuo().getCodigoFreguesia(); setFieldValue(formId, 'mnet_moradaLocalidade', moradaLocalidade); setFieldValue(formId, 'mnet_codigoPostal', codigoPostal); setFieldValue(formId, 'mnet_codigoPostalComplemento', codigoPostalComplemento); setFieldValue(formId, 'mnet_codigoFreguesiaFromCc', codigoFreguesia); // Agora para os dados para igualarem o mdc setFieldValue(formId, 'mnet_mdcAndar', moradaAndar + " " + moradaLado); setFieldValue(formId, 'mnet_mdcMorada', moradaDesignacaoVia + " " + moradaRua); setFieldValue(formId, 'mnet_mdcPorta', moradaNumeroPorta); return true; } function setFieldValue(formName, fieldName, value) { var field = document.getElementById(formName + ':' + fieldName); if (field != null) { field.value = value; } var field = document .getElementById(formName + ':hiddenFields:' + fieldName); if (field != null) { field.value = value; } } function mnet_getDataForStudent(formId, img, noCardErrorDiv, wrongCardErrorDiv) { // VERIFICA SE O CARTÃO ESTa INSERIDO if (!mnet_loadData()) { document.getElementById(noCardErrorDiv).style.display = 'block'; if (wrongCardErrorDiv != null) { if (document.getElementById(wrongCardErrorDiv) != null) { document.getElementById(wrongCardErrorDiv).style.display = 'none'; } } mnet_showBtn(); return false; } // VERIFICA SE O CARTÃO UTILIZADO ANTERIORIMENTE SE MANTÉM if (wrongCardErrorDiv != null && !mnet_checkCardPresenceForStudent(formId)) { document.getElementById(noCardErrorDiv).style.display = 'none'; document.getElementById(wrongCardErrorDiv).style.display = 'block'; mnet_showBtn(); return false; } var nomeProprio = document.getElementById('mnet_appletLeitor') .obterIndividuo().getNomeProprio(); var apelidos = document.getElementById('mnet_appletLeitor') .obterIndividuo().getApelidos(); var bi = document.getElementById('mnet_appletLeitor').obterIndividuo() .getIdentificacaoCivil(); var nif = document.getElementById('mnet_appletLeitor').obterIndividuo() .getNumeroIdentificacaoFiscal(); var utente = document.getElementById('mnet_appletLeitor').obterIndividuo() .getNumeroUtente(); var dataValidade = document.getElementById('mnet_appletLeitor') .obterIndividuo().getDataValidade(); var dataNascimento = document.getElementById('mnet_appletLeitor') .obterIndividuo().getDataNascimento(); var numSS = document.getElementById('mnet_appletLeitor').obterIndividuo() .getNumeroSegurancaSocia(); var sexo = document.getElementById('mnet_appletLeitor').obterIndividuo() .getSexo(); var foto; if (img == 1) { foto = document.getElementById('mnet_appletLeitor').obterIndividuo() .getFotografia(); } // Vamos dar os dados às textboxes setFieldValue(formId, 'mnet_name', nomeProprio); setFieldValue(formId, 'mnet_lastName', apelidos); setFieldValue(formId, 'mnet_numId', bi); setFieldValue(formId, 'mnet_numNif', nif); setFieldValue(formId, 'mnet_numUtente', utente); setFieldValue(formId, 'mnet_dataNascimento', dataNascimento); setFieldValue(formId, 'mnet_dataValidade', dataValidade); setFieldValue(formId, 'mnet_sexo', sexo); setFieldValue(formId, 'mnet_numSS', numSS); if (img == 1) { setFieldValue(formId, 'mnet_foto', foto); } return true; } function mnet_checkCardPresenceForStudent(formId) { var result = false; var numeroCartaoPresente = document.getElementById('mnet_appletLeitor') .obterIndividuo().getIdentificacaoCivil(); if (document.getElementById(formId + ':mnet_numId') != null) { var numeroCartaoNoForm = document .getElementById(formId + ':mnet_numId').value; if (numeroCartaoNoForm == null || numeroCartaoNoForm == "") { result = true; // uma vez que foi a 1ª utilização } else if (numeroCartaoPresente == numeroCartaoNoForm) { result = true; } else if (numeroCartaoPresente != numeroCartaoNoForm) { result = false; } else { result = false; } } return result; } function mnet_getDataForParent(formId, img, noCardErrorDiv, wrongCardErrorDiv) { // VERIFICA SE O CARTÃO UTILIZADO ANTERIORIMENTE SE MANTÉM if (wrongCardErrorDiv != null && !mnet_verificaCartaoPresenteForStudent(formId)) { document.getElementById(noCardErrorDiv).style.display = 'none'; document.getElementById(wrongCardErrorDiv).style.display = 'block'; mnet_showBtn(); return false; } } /** * Verifica se o leitor consegue ler do cartão * * @param noCardErrorDiv * @returns {Boolean} */ function mnet_checkCardPresence(noCardErrorDiv, wrongCardErrorDiv) { if (!mnet_loadData()) { document.getElementById(noCardErrorDiv).style.display = 'block'; if (wrongCardErrorDiv != null) { var wrongCard = document.getElementById(wrongCardErrorDiv); if (wrongCard != null) { wrongCard.style.display = 'none'; } } mnet_showBtn(); return false; } else { return true; } } /** * Evita que o CC utilizado no Aluno ou Encarregado seja utilizado para o * pai/mãe * * @param alunoId */ function mnet_checkDataIntegrityForParent(formId, alunoId, eeId, wrongCardErrorDiv, noCardErrorDiv) { var result = false; var cardReaderId = document.getElementById('mnet_appletLeitor') .obterIndividuo().getIdentificacaoCivil(); var formAlunoId = document.getElementById(formId + ":" + alunoId).value; var formEEId = document.getElementById(formId + ":" + eeId).value; if (cardReaderId == formAlunoId || cardReaderId == formEEId) { var wrongCard = document.getElementById(wrongCardErrorDiv); if (wrongCard != null) { document.getElementById(noCardErrorDiv).style.display = 'none'; wrongCard.style.display = 'block'; mnet_showBtn(); result = false; } } else { result = true; } return result; } function mnet_getPermissionToProceed() { document.getElementById('mnet_hiddenErrorInfo').style.display = 'none'; document.getElementById('mnet_hiddenErrorCartaoAutenticacao').style.display = 'none'; var numDocAut = document .getElementById('mnet_form_matriculas:mnet_numeroDocumentoAutenticado'); mnet_pressBtn(); if (!mnet_getData('mnet_form_matriculas', 0, 'mnet_hiddenErrorInfo', null, 'false', null, null)) { mnet_showBtn(); return false; } else { if (numDocAut.value != null && numDocAut.value != "") { if (numDocAut.value.substring(0, 8) != document .getElementById('mnet_form_matriculas:mnet_numId').value .substring(0, 8)) { document.getElementById('mnet_hiddenErrorCartaoAutenticacao').style.display = 'block'; mnet_showBtn(); return false; } } } } /** * Função utilizada para fazer disable nas combos de "Escola" ou "Concelho" * consoante o estado seleccionado seja "Responsável pelo processo" ou "Sem * Colocação" respectivamente. * * @param comboId * @param valueToLockBy * @returns {Boolean} */ function mnet_lockByEstado() { var callingCombo = document .getElementById("mnet_form_colocacao_manual:mnet_selectEstados"); var combo2LockEscolas = document .getElementById("mnet_form_colocacao_manual:mnet_selectEscolas"); var combo2LockConcelhos = document .getElementById("mnet_form_colocacao_manual:mnet_selectConcelhos"); if (callingCombo.value == 13) { if (combo2LockEscolas != null) { mnet_lockCombo(combo2LockEscolas); } } else if (callingCombo.value == 14) { if (combo2LockEscolas != null) { // mnet_lockCombo(combo2LockEscolas); } } else if (callingCombo.value != 13 && callingCombo.value != 14) { if (combo2LockEscolas != null) { combo2LockEscolas.disabled = false; } if (combo2LockConcelhos != null) { combo2LockConcelhos.disabled = false; } } else { combo2LockEscolas.disabled = false; combo2LockConcelhos.disabled = false; callingCombo.disabled = false; } return false; } function mnet_lockCombo(combo) { combo.value = " "; combo.disabled = true; }