Factura codigo xhtml

<?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"
                xmlns:e="http://xmlns.jcp.org/jsf/composite/extensions"> 
    <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>
        <style>
            .ui-datatable td:nth-child(1) div.ui-dt-c {
                padding: 0 0 0 0 !important;
            }
        </style>




        <b:form id="form"  prependId="false"   rendered="#{loginController.loggedIn and applicationMenu.factura.create}" onkeypress="if (event.keyCode == 13) {
                    return false;
                }">
            <h:panelGroup id="content" layout="block"> 

                <!--<a:messages id="msg" />-->
                <b:growl id="msg" />


                <b:panel title="#{msg['titleview.factura']}" look="primary">



                    <b:panelGrid id="panel" colSpans="2,4,2,4" size="xs" > 

                        <p:outputLabel  value="#{msg['field.fecha']}" />
                        <p:outputLabel  value="#{facturaController.factura.fecha}"  >
                            <f:convertDateTime pattern="dd/MMM/yyyy" />
                        </p:outputLabel>
                        <p:outputLabel  value="#{msg['field.factura']}" />
                        <p:outputLabel  value="#{facturaController.factura.numerofactura}"  />



                        <p:outputLabel value="#{msg['field.cedula']}"/>
                        <e:autocompletecliente listener="#{facturaController.handleSelectCliente}"
                                               value="#{facturaController.factura.cliente}"
                                               itemLabel="#{p.cedula} "
                                               size="35"
                                               fromstart="true"
                                               minQueryLength="5"
                                               field="cedula"
                                               update=":form:content"/>

                        <p:outputLabel value="#{msg['field.cliente']}"/>
                        <p:outputLabel value="#{facturaController.factura.cliente.nombre}"/>







                        <p:outputLabel value="#{msg['field.condicion']}"/> 
                        <b:switch value="#{facturaController.isContado}"   
                                  onText="#{msg['field.contado']}"
                                  offText="#{msg['field.credito']}"
                                  update=" :form:content"
                                  onColor="success"  
                                  offColor="danger"


                                  onchange="ajax:facturaController.onCondicionChange()"
                                  />
                        <p:spacer/>
                        <p:spacer/>

                        <p:outputLabel  value="#{msg['field.fechaentrega']}" />
                        <a:calendar value="#{facturaController.factura.fechaentrega}" 
                                    pattern="dd/MM/yyyy" id="fechaentrega"  label="#{msg['field.fechaentrega']}" />

                        <p:outputLabel  value="#{msg['field.horaentrega']}" />

                        <p:inputMask id="key" value="#{facturaController.factura.horaentrega}" mask="99:99am"/>

                        <p:outputLabel  value="#{msg['field.fechavencimiento']}" id="label_fechavencimiento" rendered="#{!facturaController.isContado}" />

                        <a:calendar value="#{facturaController.factura.fechavencimiento}" rendered="#{!facturaController.isContado}"
                                    pattern="dd/MM/yyyy" id="fechavencimiento"  label="#{msg['field.fechavencimiento']}" />

                        <p:outputLabel  value="#{msg['field.cantidadmeses']}" id="label_cantidadmeses" rendered="#{!facturaController.isContado}"/>
                        <a:inputText value="#{facturaController.factura.cantidadmeses}"  rendered="#{!facturaController.isContado}"
                                     span="4" id="cantidadmeses"  label="#{msg['field.cantidadmeses']}" />


                        <p:outputLabel  value="#{msg['field.observacion']}" />
                        <b:inputTextarea value="#{facturaController.factura.observacion}" id="observacion"  
                                         rows="2"
                                         required="true"  />
                        <p:spacer/>
                        <p:spacer/>

                        <p:outputLabel value="#{msg['field.vendedor']}"/>
                        <e:autocompleteusuario_rol_almacen listener="#{facturaController.handleSelect}"
                                                           value="#{facturaController.vendedor}"
                                                           itemLabel=" #{p.nombre}"
                                                           rolValue="VENDEDOR"
                                                           almacenValue="#{loginController.almacen.idalmacen}"
                                                           size="30"
                                                           required="true"
                                                           field="nombre"
                                                           dropdown="true"
                                                           fromstart="true"
                                                           minQueryLength="0"
                                                           update=":form:datatable"
                                                           />

                        <p:outputLabel value="#{msg['field.capturista']}"/>
                        <e:autocompleteusuario_almacen  listener="#{facturaController.handleSelect}"
                                                        value="#{facturaController.capturador}"
                                                        itemLabel=" #{p.nombre}"
                                                        size="30"
                                                        almacenValue="#{loginController.almacen.idalmacen}"
                                                        field="nombre"
                                                        required="true"
                                                        dropdown="true"
                                                        fromstart="true"
                                                        minQueryLength="0"
                                                        />





                    </b:panelGrid>

                    <p:remoteCommand name="onCellEditTable" 
                                     process="@this"
                                     action="#{facturaController.refresh()}"
                                     update=":form:msg,  panelTotales" />
                    <b:row>

                        <b:column span="12">
                            <p:dataTable
                                rowIndexVar="rowIndex" 
                                rowStyleClass="no-color"
                                id="datatable" 
                                var="item" 
                                widgetVar="datatable"
                                rendered="#{facturaController.showTable}"
                                value="#{facturaController.facturadetalleDataModel}" 
                                editable="true" 
                                editMode="cell"

                                > 
                                <p:ajax event="cellEdit" listener="#{facturaController.onCellEdit}" 
                                        oncomplete="onCellEditTable()"
                                        update=":form:msg, datatable panelTotales"
                                        />
                                <p:column headerText="#{msg['field.idarticulo']}" style="width:95px;">
                                    <p:cellEditor> 
                                        <f:facet name="output"><h:outputText value="#{item.articulo.codigo}" title="#{msg['field.disponible']}: #{item.cantidademisor}"/></f:facet>

                                        <f:facet name="input">

                                            <e:autocompletearticulo listener="#{facturaController.onArticuloChange(rowIndex,item,'factura')}"
                                                                    value="#{item.articulo}" 
                                                                    itemLabel=" #{p.codigo}"
                                                                    minQueryLength="4"  
                                                                    field="codigo"
                                                                    update=" datatable"/>



                                        </f:facet>


                                    </p:cellEditor>  

                                </p:column>
                                <p:column headerText="#{msg['field.articulo']}" style="width:275px;">
                                    <p:cellEditor>
                                        <f:facet name="output"><h:outputText value="#{item.articulo.descripcion}" /></f:facet>
                                        <f:facet name="input">
                                            <e:autocompletearticulo listener="#{facturaController.onArticuloChange(rowIndex,item,'factura')}"
                                                                    value="#{item.articulo}" 
                                                                    itemLabel=" #{p.descripcion}"
                                                                    minQueryLength="4"  
                                                                    field="descripcion"
                                                                    update="datatable"/>


                                        </f:facet>



                                    </p:cellEditor>  
                                </p:column>


                                <p:column headerText="#{msg['field.cantidad']}" style="width:45px;">
                                    <p:cellEditor>        
                                        <f:facet name="output"><h:outputText value="#{item.cantidad}" title="#{msg['field.disponible']}: #{item.cantidademisor}" /></f:facet>
                                        <f:facet name="input">
                                            <b:inputText value="#{item.cantidad}" title="#{msg['field.disponible']}: #{item.cantidademisor}"
                                                         onblur="#{facturaController.refresh}"
                                                        update=":form:msg, form:datatable form:panelTotales"/>

                                        </f:facet>

                                    </p:cellEditor>              
                                </p:column>



                                <p:column id="precio" headerText="#{msg['field.precio']}" style="width:45px;">
                                    <h:outputText value="#{item.precio}"/>

                                </p:column>
                                <p:column id="column_total" headerText="#{msg['field.total']}" style="width:45px;">
                                    <h:outputText value="#{facturaController.calcularCosto(item,rowIndex)}"/>

                                </p:column>



                                <p:column  style="width:45px;">    
                                    <f:facet name="header">
                                        <p:panelGrid columns="2" styleClass="form-group ui-panelgrid-blank" layout="grid">
                                            <b:commandButton iconAwesome="fa-plus"     

                                                             update=":form:datatable"
                                                             title="#{app['button.new']}"   
                                                             action="#{facturaController.addFila()}"
                                                             />
                                            <b:commandButton iconAwesome="fa-refresh"    

                                                             update=":form:datatable, :form:panelTotales "
                                                             title="#{app['button.refresh']}"   
                                                             action="#{facturaController.refresh()}"
                                                             />

                                        </p:panelGrid>

                                    </f:facet>


                                    <p:panelGrid columns="2" styleClass="form-group ui-panelgrid-blank" layout="grid">
                                        <p:row>
                                            <p:column> 
                                                <b:commandButton                 
                                                    iconAwesome="fa-trash-o" 
                                                    title="#{app['button.delete']}"
                                                    action="#{facturaController.onRowDelete(rowIndex)}"

                                                    > 

                                                </b:commandButton>
                                            </p:column>
                                        </p:row>
                                    </p:panelGrid>
                                </p:column>



                            </p:dataTable>
                        </b:column>

                    </b:row>
                    <p:remoteCommand  update=":form:content :form:panelTotales"
                                      name="remoteid" 
                                      actionListener="#{cc.attrs.isnew}"/>
                    <b:row>
                        <b:column span="12">
                            <b:panelGrid id="panelTotales" colSpans="2,10" size="xs"  rendered="#{facturaController.showTable}"> 

                                <p:outputLabel  value="#{msg['field.subtotal']}" />
                                <a:labelPago  span="4"  value="#{facturaController.factura.subtotal}"
                                              disabled="true"
                                              update=":form:panelTotales :form:msg"
                                              />


                                <p:outputLabel  value="#{msg['field.itbms']}" />
                                <a:labelPago  span="4"  value="#{facturaController.factura.itbms}"
                                              disabled="true"
                                              update=":form:panelTotales :form:msg"
                                              />



                                <p:outputLabel  value="#{msg['field.total']}" />
                                <a:labelPago  span="4"  value="#{facturaController.factura.total}"
                                              disabled="true"
                                              update=":form:panelTotales :form:msg"
                                              />

                                <p:outputLabel  value="#{msg['field.montoacuenta']}" />

                                    <a:inputTextPago  span="4"  value="#{facturaController.factura.montoacuenta}"
                                                      update=":form:panelTotales :form:msg"
                                                      action="#{facturaController.pagar}"  />




                                <p:outputLabel  value="#{msg['field.montoalrecibir']}" />
                                <a:inputTextPago  span="4"  value="#{facturaController.factura.montoalrecibir}"
                                                  update=":form:panelTotales :form:msg"
                                                  action="#{facturaController.pagar}"  />




                                <p:outputLabel  value="#{msg['field.descuento']}" />
                                <a:inputTextPago  span="4"  value="#{facturaController.factura.descuento}"
                                                  update=":form:panelTotales, :form:msg"
                                                  action="#{facturaController.descontar}"  />



                                <p:outputLabel   value="#{msg['field.saldo']}"  />
                                <a:labelPago span="4" value="#{facturaController.factura.saldo}"  />



                            </b:panelGrid>
                        </b:column>
                    </b:row>

                    <b:row id="rowCommandButtons" >
                        <b:column span="3">
                            <a:save rendered="#{facturaController.showTable}"

                                    save="#{facturaController.save('factura',facturaController.factura.condicion )}" />
                        </b:column>
                        <b:column span="3">
                            <b:commandButton  iconAwesome="fa-plus"         
                                              action="#{facturaController.prepare('new',facturaController.factura)}"
                                              value="#{app['button.new']}"
                                              title="#{app['button.new']}"
                                              look="primary"

                                              update=":form:content" > 
                                <f:ajax />
                            </b:commandButton>
                        </b:column>
                        <b:column span="3">

                            <b:commandButton  iconAwesome="fa-calculator"  
                                              look="success"
                                              value="#{msg['button.calculadora']}" 
                                              title="#{msg['button.calculadora']}" 
                                              update="efectivoDetails"

                                              oncomplete="PF('efectivoDialog').show();" />

                        </b:column>
                        <b:column span="3">

                            <b:commandButton immediate="true"
                                             look="primary"
                                             value="#{app['button.return']}"
                                             iconAwesome="fa-share" 
                                             title="#{app['button.search']}" 
                                             action="#{facturaController.prepare('golist',facturaController.factura)}"/>
                        </b:column>

                    </b:row>









                </b:panel>
            </h:panelGroup>

            <p:dialog widgetVar="efectivoDialog" header="#{msg['dialogo.efectivo']}" 
                      width="450" height="280"
                      styleClass="customDialog"

                      responsive="true"

                      showEffect="clip" hideEffect="clip">
                <b:panelGrid id="efectivoDetails" colSpans="2,10" size="xs" > 

                       <p:outputLabel  value="#{msg['field.acuenta']}" />


                                    <a:labelPago  value="#{facturaController.factura.montoacuenta}"  />

                    <p:outputLabel  value="#{msg['field.efectivo']}" />
                    <a:inputTextPagoDialog  value="#{facturaController.factura.efectivo}"
                                      update=":form:panelTotales :form:efectivoDetails :form:msg"
                                      action="#{facturaController.pagar}"  />







                    <p:outputLabel   value="#{msg['field.vuelto']}" />
                    <a:labelPago  value="#{facturaController.factura.vuelto}"  />


                    <b:commandButton value="#{app['button.close']}"
                                     iconAwesome="fa-close"
                                     oncomplete="PF('efectivoDialog').hide();"/>
                </b:panelGrid>
            </p:dialog>
        </b:form>

        <a:denegado renderedcondition="#{!loginController.loggedIn or !applicationMenu.factura.create}" />

        <br/><br/><br/>
    </ui:define>
</ui:composition>

Last updated