You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
			
				
					199 lines
				
				13 KiB
			
		
		
			
		
	
	
					199 lines
				
				13 KiB
			| 
								 
											2 years ago
										 
									 | 
							
								<?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:p="http://primefaces.org/ui"
							 | 
						||
| 
								 | 
							
								      xmlns:f="http://xmlns.jcp.org/jsf/core">
							 | 
						||
| 
								 | 
							
								    <ui:composition template="./template/templatePlantilla.xhtml">
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								        <ui:define name="top">
							 | 
						||
| 
								 | 
							
								            INVENTARIO
							 | 
						||
| 
								 | 
							
								          
							 | 
						||
| 
								 | 
							
								        </ui:define>
							 | 
						||
| 
								 | 
							
								        
							 | 
						||
| 
								 | 
							
								    
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								        <ui:define name="content">
							 | 
						||
| 
								 | 
							
								            <div class="card crud-demo">
							 | 
						||
| 
								 | 
							
								                <h:form id="form">
							 | 
						||
| 
								 | 
							
								                    <p:growl id="messages" showDetail="true" />
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								                    <p:toolbar>
							 | 
						||
| 
								 | 
							
								                        <p:toolbarGroup>
							 | 
						||
| 
								 | 
							
								                            <p:commandButton value="Nuevo Producto 📍" icon="pi pi-plus" actionListener="#{productosBean.prepararProducto()}"
							 | 
						||
| 
								 | 
							
								                                    update=":dialogs:manage-product-content" oncomplete="PF('manageProductDialog').show()"
							 | 
						||
| 
								 | 
							
								                               styleClass="ui-button-raised ui-button-flat"  style="margin-right: 0.5rem">
							 | 
						||
| 
								 | 
							
								                                <p:resetInput target=":dialogs:manage-product-content" />
							 | 
						||
| 
								 | 
							
								                            </p:commandButton>
							 | 
						||
| 
								 | 
							
								                        </p:toolbarGroup>
							 | 
						||
| 
								 | 
							
								                        
							 | 
						||
| 
								 | 
							
								                          <p:toolbarGroup align="right">
							 | 
						||
| 
								 | 
							
								            
							 | 
						||
| 
								 | 
							
								                <p:commandButton value="Export" icon="pi pi-upload" styleClass="ui-button-help" ajax="false">
							 | 
						||
| 
								 | 
							
								                    <p:dataExporter target="dt-products" type="pdf" fileName="Productos"></p:dataExporter>
							 | 
						||
| 
								 | 
							
								                </p:commandButton>
							 | 
						||
| 
								 | 
							
								            </p:toolbarGroup>
							 | 
						||
| 
								 | 
							
								                        
							 | 
						||
| 
								 | 
							
								                        
							 | 
						||
| 
								 | 
							
								                        
							 | 
						||
| 
								 | 
							
								                    </p:toolbar>
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								                    <p:dataTable id="dt-products" widgetVar="dtProducts" var="producto" value="#{productosBean.products}"
							 | 
						||
| 
								 | 
							
								                                 reflow="true" styleClass="products-table" 
							 | 
						||
| 
								 | 
							
								                        rowKey="#{productosBean.producto.idProducto}" paginator="true" rows="10" rowSelectMode="add" paginatorPosition="bottom">
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								                         <f:facet name="header">
							 | 
						||
| 
								 | 
							
								                            <div class="products-table-header">
							 | 
						||
| 
								 | 
							
								                                <span style="font-weight: bold">Producto</span>
							 | 
						||
| 
								 | 
							
								                                <span class="filter-container ui-input-icon-left"> <i class="pi pi-search"></i>
							 | 
						||
| 
								 | 
							
								                                    <p:inputText id="globalFilter" onkeyup="PF('dtProducts').filter()" placeholder="Search" />
							 | 
						||
| 
								 | 
							
								                                </span>
							 | 
						||
| 
								 | 
							
								                            </div>
							 | 
						||
| 
								 | 
							
								                        </f:facet>
							 | 
						||
| 
								 | 
							
								                        
							 | 
						||
| 
								 | 
							
								                         
							 | 
						||
| 
								 | 
							
								                        
							 | 
						||
| 
								 | 
							
								                        <p:column headerText="Codigo" sortBy="#{producto.codigo}" filterBy="#{producto.codigo}">
							 | 
						||
| 
								 | 
							
								                            <h:outputText value="#{producto.codigo}" />
							 | 
						||
| 
								 | 
							
								                        </p:column>
							 | 
						||
| 
								 | 
							
								                        
							 | 
						||
| 
								 | 
							
								                        
							 | 
						||
| 
								 | 
							
								                        <p:column headerText="Nombre" sortBy="#{producto.nombre}" filterBy="#{producto.nombre}">
							 | 
						||
| 
								 | 
							
								                            <h:outputText value="#{producto.nombre}" />
							 | 
						||
| 
								 | 
							
								                        </p:column>
							 | 
						||
| 
								 | 
							
								                        
							 | 
						||
| 
								 | 
							
								                         <p:column headerText="Descripcion" sortBy="#{producto.descripcion}" filterBy="#{producto.descripcion}">
							 | 
						||
| 
								 | 
							
								                            <h:outputText value="#{producto.descripcion}" />
							 | 
						||
| 
								 | 
							
								                        </p:column>
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								                        
							 | 
						||
| 
								 | 
							
								                        <p:column headerText="Categoria" sortBy="#{producto.categoriaidCategoria.nombre}" filterBy="#{producto.categoriaidCategoria.nombre}">
							 | 
						||
| 
								 | 
							
								                            <h:outputText value="#{producto.categoriaidCategoria.nombre}" />
							 | 
						||
| 
								 | 
							
								                        </p:column>
							 | 
						||
| 
								 | 
							
								                        
							 | 
						||
| 
								 | 
							
								                        <p:column headerText="Marca" sortBy="#{producto.marcaidMarca.nombre}" filterBy="#{producto.marcaidMarca.nombre}">
							 | 
						||
| 
								 | 
							
								                            <h:outputText value="#{producto.marcaidMarca.nombre}" />
							 | 
						||
| 
								 | 
							
								                        </p:column>
							 | 
						||
| 
								 | 
							
								                        
							 | 
						||
| 
								 | 
							
								                        <p:column headerText="Proveedor" sortBy="#{producto.proovedoridProovedor.proovedor}" filterBy="#{producto.proovedoridProovedor.proovedor}">
							 | 
						||
| 
								 | 
							
								                            <h:outputText value="#{producto.proovedoridProovedor.proovedor}" />
							 | 
						||
| 
								 | 
							
								                        </p:column>
							 | 
						||
| 
								 | 
							
								                        
							 | 
						||
| 
								 | 
							
								                        <p:column headerText="Ubicacion" sortBy="#{producto.ubicacionidUbicacion.pasillo}" filterBy="#{producto.ubicacionidUbicacion.pasillo}">
							 | 
						||
| 
								 | 
							
								                            <h:outputText value="#{producto.ubicacionidUbicacion.pasillo}" />
							 | 
						||
| 
								 | 
							
								                        </p:column>
							 | 
						||
| 
								 | 
							
								                        
							 | 
						||
| 
								 | 
							
								                        
							 | 
						||
| 
								 | 
							
								                     
							 | 
						||
| 
								 | 
							
								                        <p:column headerText="Precio" sortBy="#{producto.precio}" filterBy="#{producto.precio}">
							 | 
						||
| 
								 | 
							
								                            <h:outputText value="#{producto.precio}" />
							 | 
						||
| 
								 | 
							
								                        </p:column>
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								                       
							 | 
						||
| 
								 | 
							
								                        <p:column headerText="Cantidad" sortBy="#{producto.cantidadTotal}" filterBy="#{producto.cantidadTotal}">
							 | 
						||
| 
								 | 
							
								                            <h:outputText value="#{producto.cantidadTotal}" />
							 | 
						||
| 
								 | 
							
								                        </p:column>
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								                        <p:column headerText="Acciones">
							 | 
						||
| 
								 | 
							
								                            <p:commandButton icon="pi pi-pencil" update=":dialogs:manage-product-content"
							 | 
						||
| 
								 | 
							
								                                oncomplete="PF('manageProductDialog').show()"
							 | 
						||
| 
								 | 
							
								                                styleClass="rounded-button ui-button-info" process="@this"
							 | 
						||
| 
								 | 
							
								                                actionListener="#{productosBean.preparaEliminarProducto(producto)}">
							 | 
						||
| 
								 | 
							
								                                <p:resetInput target=":dialogs:manage-product-content" />
							 | 
						||
| 
								 | 
							
								                            </p:commandButton>
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								                            <p:commandButton styleClass="rounded-button ui-button-danger" icon="pi pi-trash"
							 | 
						||
| 
								 | 
							
								                                process="@this"
							 | 
						||
| 
								 | 
							
								                                actionListener="#{productosBean.preparaEliminarProducto(producto)}"
							 | 
						||
| 
								 | 
							
								                                oncomplete="PF('deleteProductDialog').show()">
							 | 
						||
| 
								 | 
							
								                            </p:commandButton>
							 | 
						||
| 
								 | 
							
								                        </p:column>
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								                    </p:dataTable>
							 | 
						||
| 
								 | 
							
								                </h:form>
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								                <h:form id="dialogs">
							 | 
						||
| 
								 | 
							
								                    <p:dialog header="Detalles del Producto" showEffect="fade" modal="true" widgetVar="manageProductDialog"
							 | 
						||
| 
								 | 
							
								                        responsive="true">
							 | 
						||
| 
								 | 
							
								                        <p:outputPanel id="manage-product-content" styleClass="ui-fluid">
							 | 
						||
| 
								 | 
							
								                            <p:outputPanel>
							 | 
						||
| 
								 | 
							
								                                <h:panelGrid columns="2">
							 | 
						||
| 
								 | 
							
								                                    <h:outputLabel value="Nombre:" for="Nombre" />   
							 | 
						||
| 
								 | 
							
								                                    <p:inputText id="Nombre" value="#{productosBean.producto.nombre}" title="Nombre" required="true" requiredMessage="El Nombre es requerido. ⚠" validatorMessage="Solo se aceptan letras. ⚠">
							 | 
						||
| 
								 | 
							
								                                        <f:validateRegex pattern="[A-Za-z]+" for="Nombre"></f:validateRegex>                              
							 | 
						||
| 
								 | 
							
								                                    </p:inputText>             
							 | 
						||
| 
								 | 
							
								                                    <h:outputLabel value="Marca:" for="Marca" />               
							 | 
						||
| 
								 | 
							
								                            <p:selectOneMenu id="Marca" value="#{productosBean.producto.marcaidMarca}" converter="selectOneMenuConverter" required="true" requiredMessage="Seleccione una marca. ⚠"> 
							 | 
						||
| 
								 | 
							
								                                <f:selectItem itemLabel="Selecciona una" itemValue="" />
							 | 
						||
| 
								 | 
							
								                                <f:selectItems value="#{demoBean.marcas}" var="item" itemLabel="#{item.nombre}" itemValue="#{item}"/>
							 | 
						||
| 
								 | 
							
								                             </p:selectOneMenu>
							 | 
						||
| 
								 | 
							
								                             <h:outputLabel value="Categoria:" for="Categoria" />   
							 | 
						||
| 
								 | 
							
								                            
							 | 
						||
| 
								 | 
							
								                             <p:selectOneMenu id="Categoria" value="#{productosBean.producto.categoriaidCategoria}" converter="selectOneMenuConverter" required="true" requiredMessage="Seleccione una categoria. ⚠"> 
							 | 
						||
| 
								 | 
							
								                                <f:selectItem itemLabel="Selecciona una" itemValue="" />
							 | 
						||
| 
								 | 
							
								                                 <f:selectItems value="#{demoBean.categorias}" var="item" itemLabel="#{item.nombre}" itemValue="#{item}"/>
							 | 
						||
| 
								 | 
							
								                             </p:selectOneMenu>
							 | 
						||
| 
								 | 
							
								                             <h:outputLabel value="Ubicacion:" for="Ubicacion" />  
							 | 
						||
| 
								 | 
							
								                             
							 | 
						||
| 
								 | 
							
								                             <p:selectOneMenu id="Ubicacion" value="#{productosBean.producto.ubicacionidUbicacion}" converter="selectOneMenuConverter" required="true" requiredMessage="Seleccione una ubicacion. ⚠"> 
							 | 
						||
| 
								 | 
							
								                                <f:selectItem itemLabel="Selecciona una" itemValue="" />
							 | 
						||
| 
								 | 
							
								                                 <f:selectItems value="#{demoBean.ubicaciones}" var="item" itemLabel="#{item.pasillo}" itemValue="#{item}"/>
							 | 
						||
| 
								 | 
							
								                              </p:selectOneMenu>
							 | 
						||
| 
								 | 
							
								                              <h:outputLabel value="Proovedor:" for="Proovedor" />   
							 | 
						||
| 
								 | 
							
								                                  <p:selectOneMenu id="Proovedor" value="#{productosBean.producto.proovedoridProovedor}" converter="selectOneMenuConverter" required="true" requiredMessage="Seleccione un proveedor. ⚠"> 
							 | 
						||
| 
								 | 
							
								                                       <f:selectItem itemLabel="Selecciona una" itemValue="" />
							 | 
						||
| 
								 | 
							
								                                      <f:selectItems value="#{demoBean.proovedor}" var="item" itemLabel="#{item.proovedor}" itemValue="#{item}"/>
							 | 
						||
| 
								 | 
							
								                              </p:selectOneMenu>
							 | 
						||
| 
								 | 
							
								                              <h:outputLabel value="Codigo:" for="Codigo" />   
							 | 
						||
| 
								 | 
							
								                              <p:inputText id="Codigo" value="#{productosBean.producto.codigo}" title="Codigo" required="true" requiredMessage="El Código es requerido. ⚠" validatorMessage="Solo se pueden introudicir letras y numeros en el codigo" >
							 | 
						||
| 
								 | 
							
								                              <f:validateRegex pattern="[A-Za-z0-9]+" for="Codigo"></f:validateRegex>                              
							 | 
						||
| 
								 | 
							
								                              </p:inputText>
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								                              <h:outputLabel value="Descripcion:" for="Descripcion" />   
							 | 
						||
| 
								 | 
							
								                              <p:inputText id="Descripcion" value="#{productosBean.producto.descripcion}" title="Descripcion" required="true" requiredMessage="La Descripción es requerida. ⚠" validatorMessage="Solo se pueden introducir letras">
							 | 
						||
| 
								 | 
							
								                              <f:validateRegex pattern="[A-Za-z\s]+" for="Descripcion"></f:validateRegex>
							 | 
						||
| 
								 | 
							
								  
							 | 
						||
| 
								 | 
							
								                              </p:inputText> 
							 | 
						||
| 
								 | 
							
								                              <h:outputLabel value="Precio:" for="Precio" />   
							 | 
						||
| 
								 | 
							
								                              <p:inputNumber id="Precio" value="#{productosBean.producto.precio}" title="Precio" required="true" minValue="0" requiredMessage="El Precio es requerido. ⚠"/> 
							 | 
						||
| 
								 | 
							
								                              <h:outputLabel value="Cantidad:" for="Cantidad" />   
							 | 
						||
| 
								 | 
							
								                              <p:inputNumber id="Cantidad" value="#{productosBean.producto.cantidadTotal}" title="Cantidad" required="true" requiredMessage="La cantidad es requeridA. ⚠" minValue="0" decimalPlaces="0"/> 
							 | 
						||
| 
								 | 
							
								                                   
							 | 
						||
| 
								 | 
							
								                                </h:panelGrid>
							 | 
						||
| 
								 | 
							
								                            </p:outputPanel>
							 | 
						||
| 
								 | 
							
								                        </p:outputPanel>
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								                        <f:facet name="footer">
							 | 
						||
| 
								 | 
							
								                            <div style="text-align: center;">
							 | 
						||
| 
								 | 
							
								                                <p:commandButton value="Guardar" icon="pi pi-save"
							 | 
						||
| 
								 | 
							
								                                                 styleClass="ui-button-raised ui-button-flat" actionListener="#{productosBean.agregarP()}"
							 | 
						||
| 
								 | 
							
								                                    update="manage-product-content" process="manage-product-content @this" />
							 | 
						||
| 
								 | 
							
								                            </div>
							 | 
						||
| 
								 | 
							
								                        </f:facet>
							 | 
						||
| 
								 | 
							
								                    </p:dialog>
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								                    <p:confirmDialog widgetVar="deleteProductDialog" showEffect="fade" width="300"
							 | 
						||
| 
								 | 
							
								                        message="¿Deseas eliminar este elemento?" header="Eliminar" severity="warn">
							 | 
						||
| 
								 | 
							
								                        <div style="display: flex; justify-content: space-between;">
							 | 
						||
| 
								 | 
							
								                            <p:commandButton value="Eliminar" icon="pi pi-trash"
							 | 
						||
| 
								 | 
							
								                                styleClass="ui-button-raised ui-button-danger ui-button-flat"
							 | 
						||
| 
								 | 
							
								                                actionListener="#{productosBean.eliminarProducto()}" process="@this"
							 | 
						||
| 
								 | 
							
								                                oncomplete="PF('deleteProductDialog').hide()" />
							 | 
						||
| 
								 | 
							
								                            <p:commandButton value="Cancelar" type="button"
							 | 
						||
| 
								 | 
							
								                                styleClass="ui-button-raised ui-button-danger-success  ui-button-flat" icon="pi pi-times"
							 | 
						||
| 
								 | 
							
								                                onclick="PF('deleteProductDialog').hide()" />
							 | 
						||
| 
								 | 
							
								                        </div>
							 | 
						||
| 
								 | 
							
								                    </p:confirmDialog>
							 | 
						||
| 
								 | 
							
								                </h:form>
							 | 
						||
| 
								 | 
							
								            </div>
							 | 
						||
| 
								 | 
							
								        </ui:define>
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    </ui:composition>
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								</html>
							 |