svn commit: r474660 - in /incubator/ofbiz/trunk/applications/pos: config/ data/ screens/default/dialog/ src/org/ofbiz/pos/event/ src/org/ofbiz/pos/screen/

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r474660 - in /incubator/ofbiz/trunk/applications/pos: config/ data/ screens/default/dialog/ src/org/ofbiz/pos/event/ src/org/ofbiz/pos/screen/

jleroux@apache.org
Author: jleroux
Date: Mon Nov 13 21:06:24 2006
New Revision: 474660

URL: http://svn.apache.org/viewvc?view=rev&rev=474660
Log:
This close https://issues.apache.org/jira/browse/OFBIZ-238 
("POS Multiple bar code product match")
by adding a dialog box with a list box to select a product
I have added the following demo data in demoRetail.xml
<GoodIdentification goodIdentificationTypeId="SKU" productId="GZ-1000" idValue="12345" .../>
to allow testing. For more see Jira issue please.

Some minor formatting stuffes also.

Added:
    incubator/ofbiz/trunk/applications/pos/screens/default/dialog/SelectProduct.xml   (with props)
    incubator/ofbiz/trunk/applications/pos/src/org/ofbiz/pos/screen/SelectProduct.java   (with props)
Modified:
    incubator/ofbiz/trunk/applications/pos/config/pos.properties
    incubator/ofbiz/trunk/applications/pos/config/pos_fr.properties
    incubator/ofbiz/trunk/applications/pos/data/DemoRetail.xml
    incubator/ofbiz/trunk/applications/pos/src/org/ofbiz/pos/event/MenuEvents.java
    incubator/ofbiz/trunk/applications/pos/src/org/ofbiz/pos/screen/LoadSale.java
    incubator/ofbiz/trunk/applications/pos/src/org/ofbiz/pos/screen/SaveSale.java

Modified: incubator/ofbiz/trunk/applications/pos/config/pos.properties
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/pos/config/pos.properties?view=diff&rev=474660&r1=474659&r2=474660
==============================================================================
--- incubator/ofbiz/trunk/applications/pos/config/pos.properties (original)
+++ incubator/ofbiz/trunk/applications/pos/config/pos.properties Mon Nov 13 21:06:24 2006
@@ -26,6 +26,7 @@
 CREDIT_CARD=CREDIT CARD
 CREDNO=Enter Card Number:
 CREDZP=Enter Billing ZipCode:
+SelectProductListDblClickTip=You may use a double click to select the current product
 DATE=DATE
 DRWR=DRAWER
 DateFormat=EEE MMM dd
@@ -55,6 +56,7 @@
 Sales_Tax=Sales Tax
 SaveASale=Save current sale
 Saving=Saving sale...
+SelectAProduct=Select a product
 Shutting_down=Shutting down...
 TOTAL=TOTAL
 TOTALD=Total Due:

Modified: incubator/ofbiz/trunk/applications/pos/config/pos_fr.properties
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/pos/config/pos_fr.properties?view=diff&rev=474660&r1=474659&r2=474660
==============================================================================
--- incubator/ofbiz/trunk/applications/pos/config/pos_fr.properties (original)
+++ incubator/ofbiz/trunk/applications/pos/config/pos_fr.properties Mon Nov 13 21:06:24 2006
@@ -26,6 +26,7 @@
 CREDIT_CARD=Carte(s) de cr\u00E9dit
 CREDNO=Entrez le n\u00B0 de la carte :
 CREDZP=Entrez le code postal de facturation :
+SelectProductListDblClickTip=Vous pouvez utiliser le double clic pour chosir un produit
 DATE=Date
 DRWR=Tiroir
 DateFormat=EE dd MMM
@@ -55,6 +56,7 @@
 Sales_Tax=TVA
 SaveASale=Sauver la vente en cours
 Saving=Enregistrement de la vente...
+SelectAProduct=S\u00E9lectionnez un produit
 Shutting_down=Arr\u00EAt en cours...
 TOTAL=Total
 TOTALD=Total d\u00FB :

Modified: incubator/ofbiz/trunk/applications/pos/data/DemoRetail.xml
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/pos/data/DemoRetail.xml?view=diff&rev=474660&r1=474659&r2=474660
==============================================================================
--- incubator/ofbiz/trunk/applications/pos/data/DemoRetail.xml (original)
+++ incubator/ofbiz/trunk/applications/pos/data/DemoRetail.xml Mon Nov 13 21:06:24 2006
@@ -71,6 +71,7 @@
 
     <!-- Use these SKUs in the POS terminal -->
     <GoodIdentification goodIdentificationTypeId="SKU" productId="GZ-1000" idValue="12345" lastUpdatedStamp="2005-07-12 06:31:15.251" lastUpdatedTxStamp="2005-07-12 06:31:14.897" createdStamp="2005-07-12 06:31:15.251" createdTxStamp="2005-07-12 06:31:14.897"/>
+    <GoodIdentification goodIdentificationTypeId="OTHER_ID" productId="GZ-1001" idValue="12345" lastUpdatedStamp="2005-07-12 06:31:15.251" lastUpdatedTxStamp="2005-07-12 06:31:14.897" createdStamp="2005-07-12 06:31:15.251" createdTxStamp="2005-07-12 06:31:14.897"/>
     <GoodIdentification goodIdentificationTypeId="SKU" productId="GZ-1001" idValue="67890" lastUpdatedStamp="2005-07-12 06:31:32.803" lastUpdatedTxStamp="2005-07-12 06:31:32.749" createdStamp="2005-07-12 06:31:32.803" createdTxStamp="2005-07-12 06:31:32.749"/>
 
 

Added: incubator/ofbiz/trunk/applications/pos/screens/default/dialog/SelectProduct.xml
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/pos/screens/default/dialog/SelectProduct.xml?view=auto&rev=474660
==============================================================================
--- incubator/ofbiz/trunk/applications/pos/screens/default/dialog/SelectProduct.xml (added)
+++ incubator/ofbiz/trunk/applications/pos/screens/default/dialog/SelectProduct.xml Mon Nov 13 21:06:24 2006
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright 2001-2006 The Apache Software Foundation
+    
+    Licensed under the Apache License, Version 2.0 (the "License"); you may not
+    use this file except in compliance with the License. You may obtain a copy of
+    the License at
+    
+    http://www.apache.org/licenses/LICENSE-2.0
+    
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+    License for the specific language governing permissions and limitations
+    under the License.
+-->
+<XPage class="net.xoetrope.swing.XDialog">
+    <Components>
+        <Panel name="salesPanel" x="0" y="0" w="680" h="420" style="menu">
+            <ScrollPane name="scroolList" x="20" y="20" w="400" h="372">
+                <List name="productsList" x="0" y="0" w="400" h="400" style="editAndList"/>
+            </ScrollPane>
+            <Button name="BtnCancel" x="460" y="20" w="180" h="44" content="Cancel" style="dialogButton"/>
+            <Button name="BtnSelect" x="460" y="80" w="180" h="44" content="Add" style="dialogButton"/>
+        </Panel>
+    </Components>
+</XPage>
\ No newline at end of file

Propchange: incubator/ofbiz/trunk/applications/pos/screens/default/dialog/SelectProduct.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/ofbiz/trunk/applications/pos/screens/default/dialog/SelectProduct.xml
------------------------------------------------------------------------------
    svn:keywords = "Date Rev Author URL Id"

Propchange: incubator/ofbiz/trunk/applications/pos/screens/default/dialog/SelectProduct.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: incubator/ofbiz/trunk/applications/pos/src/org/ofbiz/pos/event/MenuEvents.java
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/pos/src/org/ofbiz/pos/event/MenuEvents.java?view=diff&rev=474660&r1=474659&r2=474660
==============================================================================
--- incubator/ofbiz/trunk/applications/pos/src/org/ofbiz/pos/event/MenuEvents.java (original)
+++ incubator/ofbiz/trunk/applications/pos/src/org/ofbiz/pos/event/MenuEvents.java Mon Nov 13 21:06:24 2006
@@ -15,6 +15,7 @@
  */
 package org.ofbiz.pos.event;
 
+import java.util.Hashtable;
 import java.util.List;
 import java.util.ListIterator;
 import java.awt.AWTEvent;
@@ -28,6 +29,8 @@
 import org.ofbiz.pos.config.ButtonEventConfig;
 import org.ofbiz.pos.component.Input;
 import org.ofbiz.pos.component.Journal;
+import org.ofbiz.pos.screen.LoadSale;
+import org.ofbiz.pos.screen.SelectProduct;
 import org.ofbiz.pos.screen.PosScreen;
 import org.ofbiz.entity.GenericValue;
 import org.ofbiz.entity.util.EntityUtil;
@@ -148,17 +151,20 @@
                     ListIterator it = items.listIterator();
                     if (it.hasNext()) {
                         GenericValue product = (GenericValue) it.next();
-                        productId = product.getString("productId");
-                    
+                        productId = product.getString("productId");                    
+                        Hashtable productsMap = new Hashtable();
+                        productsMap.put(product.getString("productId"), product.get("internalName"));
                         while (it.hasNext()) {
                             product = (GenericValue) it.next();
                             if (!productId.equals(product.getString("productId"))) {
-                                productId = null;
-                                Debug.logInfo("Multiple products found; need to select one from the list", module);
-                                break;
+                                productsMap.put(product.getString("productId"), product.get("internalName"));
                             }
                         }
-                    }
+                        if (productsMap.size() > 0) {
+                            SelectProduct SelectProduct = new SelectProduct(productsMap, trans, pos);
+                            productId = SelectProduct.openDlg();
+                        }
+                    }                    
                 }
             } catch (GeneralException e) {
                 Debug.logError(e, module);
@@ -182,7 +188,7 @@
 
         // clear the qty flag
         input.clearFunction("QTY");
-        
+
         // re-calc tax
         trans.calcTax();
 

Modified: incubator/ofbiz/trunk/applications/pos/src/org/ofbiz/pos/screen/LoadSale.java
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/pos/src/org/ofbiz/pos/screen/LoadSale.java?view=diff&rev=474660&r1=474659&r2=474660
==============================================================================
--- incubator/ofbiz/trunk/applications/pos/src/org/ofbiz/pos/screen/LoadSale.java (original)
+++ incubator/ofbiz/trunk/applications/pos/src/org/ofbiz/pos/screen/LoadSale.java Mon Nov 13 21:06:24 2006
@@ -51,7 +51,7 @@
     protected DefaultListModel m_listModel = null;
     protected static PosTransaction m_trans = null;
 
-    //TODO : make getter and setter for members (ie m_*) if needed (extern calls)
+    //TODO : make getter and setter for members (ie m_*) if needed (extern calls). For that in Eclipse use Source/Generate Getters and setters
 
     public LoadSale(Hashtable saleMap, PosTransaction trans, PosScreen page) {
         m_saleMap.putAll(saleMap);

Modified: incubator/ofbiz/trunk/applications/pos/src/org/ofbiz/pos/screen/SaveSale.java
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/pos/src/org/ofbiz/pos/screen/SaveSale.java?view=diff&rev=474660&r1=474659&r2=474660
==============================================================================
--- incubator/ofbiz/trunk/applications/pos/src/org/ofbiz/pos/screen/SaveSale.java (original)
+++ incubator/ofbiz/trunk/applications/pos/src/org/ofbiz/pos/screen/SaveSale.java Mon Nov 13 21:06:24 2006
@@ -44,7 +44,7 @@
     protected static PosTransaction m_trans = null;
     public static SimpleDateFormat sdf = new SimpleDateFormat(UtilProperties.getMessage("pos","DateTimeFormat",Locale.getDefault()));
 
-    //TODO : make getter and setter for members (ie m_*) if needed (extern calls)
+    //TODO : make getter and setter for members (ie m_*) if needed (extern calls).  For that in Eclipse use Source/Generate Getters and setters
 
     public SaveSale(PosTransaction trans, PosScreen page) {
         m_trans = trans;

Added: incubator/ofbiz/trunk/applications/pos/src/org/ofbiz/pos/screen/SelectProduct.java
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/pos/src/org/ofbiz/pos/screen/SelectProduct.java?view=auto&rev=474660
==============================================================================
--- incubator/ofbiz/trunk/applications/pos/src/org/ofbiz/pos/screen/SelectProduct.java (added)
+++ incubator/ofbiz/trunk/applications/pos/src/org/ofbiz/pos/screen/SelectProduct.java Mon Nov 13 21:06:24 2006
@@ -0,0 +1,128 @@
+/*
+ * Copyright 2001-2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+package org.ofbiz.pos.screen;
+
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Map;
+
+import javax.swing.DefaultListModel;
+import javax.swing.ListSelectionModel;
+
+import net.xoetrope.swing.XButton;
+import net.xoetrope.swing.XDialog;
+import net.xoetrope.swing.XList;
+import net.xoetrope.xui.XPage;
+
+import org.ofbiz.base.util.Debug;
+import org.ofbiz.base.util.UtilProperties;
+import org.ofbiz.pos.PosTransaction;
+
+
+public class SelectProduct extends XPage {
+
+    /**
+     * To choose a product in a list of products whith the same bar code
+     */
+    public static final String module = SelectProduct.class.getName();
+    protected static PosScreen m_pos = null;
+    protected XDialog m_dialog = null;
+    static protected Hashtable m_productsMap = new Hashtable();
+    protected XList m_productsList = null;
+    protected XButton m_cancel = null;
+    protected XButton m_select = null;
+    protected DefaultListModel m_listModel = null;
+    protected static PosTransaction m_trans = null;
+    protected static String m_productIdSelected = null;
+
+    //TODO : make getter and setter for members (ie m_*) if needed (extern calls). For that in Eclipse use Source/Generate Getters and setters
+
+    public SelectProduct(Hashtable saleMap, PosTransaction trans, PosScreen page) {
+        m_productsMap.putAll(saleMap);
+        m_trans = trans;
+        m_pos = page;
+    }
+
+    public String openDlg() {
+        XDialog dlg = (XDialog) pageMgr.loadPage(m_pos.getScreenLocation() + "/dialog/SelectProduct");
+        m_dialog = dlg;
+        dlg.setCaption(UtilProperties.getMessage("pos", "SelectAProduct", Locale.getDefault()));
+        //dlg.setModal(true);
+        m_productsList = (XList) dlg.findComponent("productsList");
+        addMouseHandler(m_productsList, "DoubleClick");
+
+        m_cancel = (XButton) dlg.findComponent("BtnCancel");
+        m_select = (XButton) dlg.findComponent("BtnSelect");
+        addMouseHandler(m_cancel, "cancel");
+        addMouseHandler(m_select, "selectProduct");
+
+        m_listModel = new DefaultListModel();
+        for (Iterator i = m_productsMap.entrySet().iterator(); i.hasNext();) {
+            Object o = i.next();
+            Map.Entry entry = (Map.Entry)o;
+            String val = entry.getValue().toString();
+            m_listModel.addElement(val);
+        }
+        m_productsList.setModel(m_listModel);
+        m_productsList.setVisibleRowCount(-1);
+        m_productsList.ensureIndexIsVisible(m_productsList.getItemCount());
+        m_productsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+        m_productsList.setToolTipText(UtilProperties.getMessage("pos", "SelectProductListDblClickTip", Locale.getDefault()));
+
+        dlg.pack();
+        dlg.showDialog(this);
+        return m_productIdSelected;
+    }
+
+    public synchronized void DoubleClick() {
+        if (wasMouseDoubleClicked()) {
+            selectProductId();
+        }
+    }
+
+    public synchronized void cancel() {
+        if (wasMouseClicked()) {
+            closeDlg();
+        }
+    }
+
+    public synchronized void selectProduct() {
+        if (wasMouseClicked()) {
+            selectProductId();
+        }
+    }
+
+    private void selectProductId() {
+        if (null != m_productsList.getSelectedValue()) {
+            String product = (String) m_productsList.getSelectedValue();
+            Iterator i = m_productsMap.entrySet().iterator();
+            while(i.hasNext()) {
+                Object o = i.next();
+                Map.Entry entry = (Map.Entry)o;
+                String val = entry.getValue().toString();
+                if (val == product) {
+                    m_productIdSelected = entry.getKey().toString();
+                }
+            }
+        }
+        closeDlg();
+    }
+
+    private void closeDlg() {
+        m_dialog.closeDlg();
+    }
+}
\ No newline at end of file

Propchange: incubator/ofbiz/trunk/applications/pos/src/org/ofbiz/pos/screen/SelectProduct.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/ofbiz/trunk/applications/pos/src/org/ofbiz/pos/screen/SelectProduct.java
------------------------------------------------------------------------------
    svn:keywords = "Date Rev Author URL Id"

Propchange: incubator/ofbiz/trunk/applications/pos/src/org/ofbiz/pos/screen/SelectProduct.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain