<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
< html xmlns = "http://www.w3.org/1999/xhtml"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:p="http://primefaces.org/ui">
< body >
< ui:composition template = "./template/listas.xhtml" >
< ui:define name = "top" >
< / ui:define >
< ui:define name = "content" >
< f:view >
< f:metadata >
< f:viewParam name = "rol" value = "#{demoBeanLogin.rol}" / >
< f:event type = "preRenderView" listener = "#{demoBeanLogin.verificarAcceso('admin')}" / >
< / f:metadata >
< div >
< h:form >
< p:menubar >
< p:menuitem value = "Productos" action = "productoLista.xhtml" ajax = "false" / >
< p:menuitem value = "Marcas" action = "marcaLista.xhtml" ajax = "false" / >
< p:menuitem value = "Proveedores" action = "proveedorLista.xhtml" ajax = "false" / >
< p:menuitem value = "Ubicaciones" action = "ubicacionLista.xhtml" ajax = "false" / >
< p:menuitem value = "Usuarios" action = "usuariosLista.xhtml" disabled = "true" ajax = "false" / >
< p:submenu label = "Opciones" icon = "pi pi-fw pi-list" >
< p:menuitem value = "Paises"
icon="pi pi-globe"
oncomplete="PF('pais').show()"
update="paisDialog"
actionListener="#{demoBeanPaises.prepararNuevo()}"/>
< p:menuitem value = "Estados"
icon="pi pi-map"
oncomplete="PF('estado').show()"
update="estadosDialog"
actionListener="#{demoBeanEstados.prepararNuevo()}"/>
< p:menuitem value = "Tipos" icon = "pi pi-tags" / >
<!-- <p:divider /> -->
< / p:submenu >
< / p:menubar >
< / h:form >
<!-- dialogos externos -->
< p:dialog id = "rolD" widgetVar = "rol" responsive = "true" showEffect = "fade" modal = "true" resizable = "false" >
< ui:include src = "roles.xhtml" / >
< / p:dialog >
< p:dialog id = "paisDialog" widgetVar = "pais" responsive = "true" showEffect = "fade" modal = "true" resizable = "false" >
< ui:include src = "paises.xhtml" / >
< / p:dialog >
< p:dialog id = "estadosDialog" widgetVar = "estado" responsive = "true" showEffect = "fade" modal = "true" resizable = "false" >
< ui:include src = "estados.xhtml" / >
< / p:dialog >
< / div >
< h:form id = "userTable" >
< p:growl id = "messages" showDetail = "true" / >
< p:dataTable id = "table" value = "#{demoBeanUsuarios.usuarios}" var = "item"
filteredValue="#{demoBeanUsuarios.usuariosFilter}"
globalFilterFunction="#{demoBeanUsuarios.globalFilterFunction}"
widgetVar="filter"
paginator="true" rows="10" rowSelectMode="add" paginatorPosition="bottom"
resizableColumns="true"
showGridlines="true"
>
< f:facet name = "header" >
< div style = "display: flex; align-items: center;" >
< div style = "flex: 1;" >
< p:commandButton actionListener = "#{demoBeanUsuarios.prepararNuevo()}" oncomplete = "PF('user').show()" update = ":dialogForm" value = "Nuevo" icon = "pi pi-plus" style = "margin-top: 5px;" ajax = "true" / >
< / div >
< div style = "flex: 1; text-align: center;" > <!-- Div para el texto centrado -->
< header style = "display: flex; justify-content: center; font-size: 30px;" > < strong > Usuarios< / strong > < / header >
< / div >
< div style = "flex: 1; text-align: right;" >
< div class = "ui-input-icon-left mr-2" >
< i class = "pi pi-fw pi-search" / >
< p:inputText id = "globalFilter" onkeyup = "PF('filter').filter()"
placeholder="Buscar usuario"
/>
< / div >
< / div >
< / div >
< / f:facet >
< p:column responsivePriority = "1" style = "text-align: center;" >
< f:facet name = "header" >
< h:outputText value = "Nombre" / >
< / f:facet >
< h:outputText value = "#{item.nombre}" / >
< / p:column >
< p:column responsivePriority = "2" style = "text-align: center;" >
< f:facet name = "header" >
< h:outputText value = "Apellido P" / >
< / f:facet >
< h:outputText value = "#{item.apellidoPaterno}" / >
< / p:column >
< p:column responsivePriority = "2" style = "text-align: center;" >
< f:facet name = "header" >
< h:outputText value = "Contraseña" / >
< / f:facet >
< h:outputText value = "#{item.contrasenia}" / >
< / p:column >
< p:column responsivePriority = "3" style = "text-align: center;" >
< f:facet name = "header" >
< h:outputText value = "Rol" / >
< / f:facet >
< h:outputText value = "#{item.rolesId.rol}" / >
< / p:column >
< p:column responsivePriority = "3" style = "text-align: center;" >
< f:facet name = "header" >
< h:outputText value = "Email" / >
< / f:facet >
< h:outputText value = "#{item.email}" / >
< / p:column >
< p:column responsivePriority = "4" style = "text-align: center;" >
< f:facet name = "header" >
< h:outputText value = "Telefono" / >
< / f:facet >
< h:outputText value = "#{item.telefono}" / >
< / p:column >
< p:column responsivePriority = "3" style = "text-align: center;" >
< f:facet name = "header" >
< h:outputText value = "Estado" / >
< / f:facet >
< h:outputText value = "#{item.estadosId.nombre}" / >
< / p:column >
< p:column responsivePriority = "4" style = "text-align: center;" >
< f:facet name = "header" >
< h:outputText value = "Domicilio" / >
< / f:facet >
< h:outputText value = "#{item.domicilio}" / >
< / p:column >
< p:column responsivePriority = "5" style = "text-align: center;" >
< f:facet name = "header" >
< h:outputText value = "Estatus" / >
< / f:facet >
< h:outputText value = "#{item.estado == 2 ? 'Activo':'Inactivo'}" / >
< / p:column >
< p:column responsivePriority = "6" style = "text-align: center;" >
< f:facet name = "header" >
< h:outputText value = "Opciones" / >
< / f:facet >
< p:commandButton actionListener = "#{demoBeanUsuarios.rellenarEditar(item)}" oncomplete = "PF('user').show()" update = ":dialogForm" icon = "pi pi-fw pi-pencil" styleClass = "ui-button-secondary" ajax = "true" / >
< p:commandButton actionListener = "#{demoBeanUsuarios.prepararEliminar(item)}" icon = "pi pi-trash" style = "margin-left: 5px" oncomplete = "PF('userD').show()" update = ":dialogDelete" styleClass = "ui-button-danger" ajax = "true" / >
< / p:column >
< / p:dataTable >
< / h:form >
< p:dialog id = "dialogForm" header = "#{demoBeanUsuarios.titulo}" widgetVar = "user" responsive = "true" showEffect = "fade" modal = "true" resizable = "false" >
< h:form >
< p:growl id = "growl" showDetail = "true" for = "mensajeUsuario" / >
< h:panelGrid columns = "6" cellpadding = "7" >
< p:outputLabel value = "Nombre:" for = "nombre" / >
< p:inputText id = "nombre" value = "#{demoBeanUsuarios.usuario.nombre}" title = "Nombre" required = "true" validatorMessage = "nombre no valido"
requiredMessage="Este campo no puede estar vacio"
style="width: 223px">
< f:validateRegex pattern = "\b[A-ZÁÉÍÓÚÜÑ][a-záéíóúüñ]{1,}(?:\s+[A-ZÁÉÍÓÚÜÑ][a-záéíóúüñ]{1,})*\b"
for="nombre" />
< / p:inputText >
< p:outputLabel value = "Apellido Paterno:" for = "apellidoPaterno" / >
< p:inputText id = "apellidoPaterno" value = "#{demoBeanUsuarios.usuario.apellidoPaterno}" title = "ApellidoPaterno" required = "true" validatorMessage = "apellido no valido"
requiredMessage="Este campo no puede estar vacio"
style="width: 223px">
< f:validateRegex pattern = "^\b[A-ZÁÉÍÓÚÜÑ][a-záéíóúüñ]{1,}\b$"
for="apellidoPaterno" />
< / p:inputText >
< p:outputLabel value = "Rol" for = "rolId" / >
< p:selectOneMenu id = "rolId"
value="#{demoBeanUsuarios.usuario.rolesId}"
converter="selectOneMenuConverter"
required="true"
requiredMessage="Se necesita un rol" >
< f:selectItems value = "#{demoBeanRoles.roles}"
var="item"
itemLabel="#{item.rol}"
itemValue="#{item}"/>
< / p:selectOneMenu >
< p:outputLabel > < / p:outputLabel >
< p:message id = "alert" for = "nombre" / >
< p:outputLabel > < / p:outputLabel >
< p:message id = "alertA" for = "apellidoPaterno" / >
< p:outputLabel > < / p:outputLabel >
< p:message id = "alertRol" for = "rolId" / >
< p:outputLabel value = "Contraseña:" for = "contraseña" / >
< p:password id = "contraseña" value = "#{demoBeanUsuarios.usuario.contrasenia}" title = "contraseña" toggleMask = "true" redisplay = "true" required = "true" validatorMessage = "contraseña no valida" requiredMessage = "Este campo no puede estar vacio"
feedback="true"
placeholder="mayusculas y numeros"
promptLabel="Ingresa tu contraseña" weakLabel="Débil"
goodLabel="Buena" strongLabel="Fuerte"
style="width: 223px">
< f:validateRegex pattern = "^(?=.*[A-Z])(?=.*\d).+$"
for="contraseña"/>
< / p:password >
< p:outputLabel value = "Email:" for = "email" / >
< p:inputText id = "email" value = "#{demoBeanUsuarios.usuario.email}" title = "Email" required = "true" validatorMessage = "correo no valido"
requiredMessage="Este campo no puede estar vacio"
style="width: 223px">
< f:validateRegex pattern = "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$"
for="email" />
< / p:inputText >
< p:outputLabel value = "Telefono:" for = "telefono" / >
< p:inputText id = "telefono" value = "#{demoBeanUsuarios.usuario.telefono}" title = "Telefono" required = "true" validatorMessage = "numero de telefono no valido"
requiredMessage="Este campo no puede estar vacio"
style="width: 223px">
< f:validateRegex pattern = "^\d{10}$"
for="telefono" />
< / p:inputText >
< p:outputLabel > < / p:outputLabel >
< p:message id = "alertC" for = "contraseña" / >
< p:outputLabel > < / p:outputLabel >
< p:message id = "alertE" for = "email" / >
< p:outputLabel > < / p:outputLabel >
< p:message id = "alertT" for = "telefono" / >
< p:outputLabel value = "Domicilio:" for = "domicilio" / >
< p:inputText id = "domicilio" value = "#{demoBeanUsuarios.usuario.domicilio}" title = "Domicilio" required = "true" validatorMessage = "domicilio no valido"
requiredMessage="Este campo no puede estar vacio"
style="width: 223px">
< f:validateRegex pattern = "^[A-Z].*#\d+.*"
for="domicilio" /><!-- validar Domicilio -->
< / p:inputText >
< p:outputLabel value = "Estado" for = "state" / >
< p:selectOneMenu id = "state"
value="#{demoBeanUsuarios.usuario.estadosId}"
converter="selectOneMenuConverter"
required="true"
requiredMessage="Se necesita un estado" >
< f:selectItems value = "#{demoBeanEstados.estados}"
var="item"
itemLabel="#{item.nombre}"
itemValue="#{item}"/>
< / p:selectOneMenu >
< p:outputLabel > < / p:outputLabel >
< p:message id = "alertS" for = "state" / >
< p:outputLabel > < / p:outputLabel >
< p:message id = "alertD" for = "domicilio" / >
< / h:panelGrid >
< footer style = "display: flex; margin-top: 20px; justify-content: flex-end;" >
< p:commandButton action = "#{demoBeanUsuarios.agregar()}" rendered = "#{demoBeanUsuarios.nuevo}"
update="growl,userTable:table,nombre,apellidoPaterno,email,telefono,contraseña,domicilio,state,rolId,alert,alertA,alertE,alertT,alertC,alertD,alertRol,alertS"
styleClass="ui-button-success" style="width: 50px;" icon="pi pi-save"
ajax="true"/>
< p:commandButton action = "#{demoBeanUsuarios.editarUsuario()}" icon = "pi pi-save"
styleClass="ui-button-success"
update="growl,userTable:table,nombre,apellidoPaterno,email,telefono,contraseña,domicilio,state,rolId,alert,alertA,alertE,alertT,alertC,alertD,alertRol,alertS"
style="width: 50px;" rendered="#{!demoBeanUsuarios.nuevo}" ajax="true"/>
< p:commandButton action = "usuariosLista.xhtml" style = "margin-left: 5px; width: 50px; " immediate = "true" icon = "pi pi-times" ajax = "false" styleClass = "ui-button-danger" / >
< / footer >
< / h:form >
< / p:dialog >
< p:dialog id = "dialogDelete" header = "#{demoBeanUsuarios.titulo}" widgetVar = "userD" responsive = "true" showEffect = "fade" modal = "true" resizable = "false" >
< h:form >
< h:panelGrid columns = "2" cellpadding = "7" >
< h:outputText value = "Nombre:" style = "font-weight: bold;" / >
< h:outputText value = "#{demoBeanUsuarios.usuario.nombre}" title = "Nombre" / >
< h:outputText value = "ApellidoPaterno:" style = "font-weight: bold;" / >
< h:outputText value = "#{demoBeanUsuarios.usuario.apellidoPaterno}" title = "ApellidoPaterno" / >
< h:outputText value = "Contraseña:" style = "font-weight: bold;" / >
< h:outputText value = "#{demoBeanUsuarios.usuario.contrasenia}" title = "Contraseña" / >
< h:outputText value = "Rol:" style = "font-weight: bold;" / >
< h:outputText value = "#{demoBeanUsuarios.usuario.rolesId.rol}" title = "Rol" / >
< h:outputText value = "Email:" style = "font-weight: bold;" / >
< h:outputText value = "#{demoBeanUsuarios.usuario.email}" title = "Email" / >
< h:outputText value = "Telefono:" style = "font-weight: bold;" / >
< h:outputText value = "#{demoBeanUsuarios.usuario.telefono}" title = "Telefono" / >
< h:outputText value = "Estado:" style = "font-weight: bold;" / >
< h:outputText value = "#{demoBeanUsuarios.usuario.estadosId.nombre}" title = "Estado" / >
< h:outputText value = "Domicilio:" style = "font-weight: bold;" / >
< h:outputText value = "#{demoBeanUsuarios.usuario.domicilio}" title = "Domicilio" / >
< h:outputText value = "Estatus:" style = "font-weight: bold;" / >
< h:outputText value = "#{demoBeanUsuarios.usuario.estado == 2 ? 'Activo':'Inactivo'}" title = "Estatus" / >
< / h:panelGrid >
< footer style = "display: flex; margin-top: 20px; justify-content: flex-end;" >
< p:commandButton actionListener = "#{demoBeanUsuarios.eliminarUsuario()}" ajax = "true"
icon="pi pi-trash"
update="userTable:table"
styleClass="ui-button-warning"
style=" width: 50px; "
/>
< p:commandButton action = "usuariosLista.xhtml" immediate = "true" ajax = "false"
icon="pi pi-times"
styleClass="ui-button-danger"
style="margin-left: 5px; width: 50px;"
/>
< / footer >
< / h:form >
< / p:dialog >
< / f:view >
< / ui:define >
< / ui:composition >
< / body >
< / html >