Cambiar numero de cedula
PreviousFormulario con llave secundaria sin mostrar autoincrementableNextFormulario referenciado (Grupoarticulo->Modelo)
Last updated
Last updated
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html>
<ui:composition template="/layout/template.xhtml"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:b="http://bootsfaces.net/ui"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
xmlns:a="http://xmlns.jcp.org/jsf/composite/avbravo">
<ui:define name="content">
<!--<h:outputStylesheet library="bsf" name="css/thumbnails.css"/>-->
<style>
.thumbnail { max-width: 100%; }
img.thumbnail:hover, img.thumbnail:focus {
border: 1px solid;
border-color: #428BCA;
}
</style>
<h1>#{msg['titleview.changecedula']}</h1>
<hr/>
<b:form id="form" prependId="false" rendered="#{loginController.loggedIn and applicationMenu.clientecambiarcedula.edit}" onkeypress="if (event.keyCode == 13) {
return false;
}">
<h:panelGroup id="content" layout="block">
<p:remoteCommand update=":form:content :form:panel"
name="remoteid"
actionListener="#{clienteController.findByCedula()}"/>
<a:messages id="msg"/>
<b:panel title="#{msg['titleview.changecedula']}">
<b:panelGrid id="panel" colSpans="2,10" size="xs" rendered="#{loginController.loggedIn}">
<p:outputLabel value="#{msg['field.cedula']}" />
<b:inputText
style="text-transform: uppercase"
placeholder="#{app['info.ingresenuevodato']}"
value="#{clienteController.cliente.cedula}"
required="false"
requiredMessage="#{msg['field.cedula']} #{app['info.required']}"
immediate="true"
onkeypress="if (event.keyCode == 13) {
remoteid();
return false;
}">
<f:facet name="prepend">
<b:commandButton iconAwesome="fa-plus"
look="success"
title="#{app['button.new']}"
action="#{clienteController.isNew()}" update=":form:content" >
<f:ajax />
</b:commandButton>
</f:facet>
<f:facet name="append">
<b:commandButton immediate="true"
look="primary"
iconAwesome="fa-search"
update=":form:content "
title="#{app['button.search']}"
action="#{clienteController.findByCedula()}"/>
</f:facet>
</b:inputText>
<p:outputLabel value="#{msg['field.nombre']}" rendered="#{clienteController.writable}"/>
<p:outputLabel value="#{clienteController.cliente.nombre}" id="nombre" rendered="#{clienteController.writable}" />
<p:outputLabel value="#{msg['field.cedulanueva']}" rendered="#{clienteController.writable}"/>
<a:inputText value="#{clienteController.cedulanueva}" id="cedula2" required="true" rendered="#{clienteController.writable}" />
<b:commandButton
look="primary"
iconAwesome="fa-edit"
title="#{app['button.edit']}"
rendered="#{clienteController.writable}"
action="#{clienteController.editCedula()}"
update=":form:content" />
</b:panelGrid>
</b:panel>
</h:panelGroup>
</b:form>
<a:denegado renderedcondition="#{!loginController.loggedIn or ! applicationMenu.clientecambiarcedula.edit}" />
<br/><br/><br/>
</ui:define>
</ui:composition> // <editor-fold defaultstate="collapsed" desc="findByCedula()">
public String findByCedula() {
try {
if (JsfUtil.isVacio(cliente.getCedula())) {
writable = false;
return "";
}
cliente.setCedula(cliente.getCedula().toUpperCase());
writable = true;
List<Cliente> list = clienteRepository.findBy(new Document("cedula", cliente.getCedula()));
if (list.isEmpty()) {
writable = false;
JsfUtil.warningMessage(rf.getAppMessage("warning.idnotexist"));
return "";
} else {
writable = true;
cliente = list.get(0);
fiador = new Fiador();
clienteSelected = cliente;
}
} catch (Exception e) {
JsfUtil.errorMessage("findByCedula()" + e.getLocalizedMessage());
}
return "";
}
// </editor-fold>// <editor-fold defaultstate="collapsed" desc="editCedula">
public String editCedula() {
try {
if(cliente.getCedula().equals(cedulanueva)){
JsfUtil.warningMessage(rf.getMessage("warning.cedulasiguales"));
return "";
}
Integer c = clienteRepository.count(new Document("cedula", cedulanueva));
if (c >= 1) {
JsfUtil.warningMessage(rf.getMessage("warning.clienteceduladuplicada"));
return "";
}
cliente.setCedula(cedulanueva);
revisionHistoryStoreejbRepository.save(revisionHistoryServices.getRevisionHistory(cliente.getIdcliente().toString(), loginController.getUsername(),
"update", "cliente", clienteRepository.toDocument(cliente).toString()));
clienteRepository.update(cliente);
JsfUtil.successMessage(rf.getAppMessage("info.update"));
} catch (Exception e) {
JsfUtil.errorMessage("edit()" + e.getLocalizedMessage());
}
return "";
}// </editor-fold> // <editor-fold defaultstate="collapsed" desc="clearCedula()">
public String clearCedula(){
try {
cliente = new Cliente();
cliente.setCedula("");
} catch (Exception e) {
JsfUtil.errorMessage("clearCedula() "+e.getLocalizedMessage() );
}
return "";
}
// </editor-fold>