svn commit: r595231 - in /ofbiz/trunk/specialpurpose/pos: config/ screens/default/dialog/ screens/default/menu/ src/org/ofbiz/pos/ 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: r595231 - in /ofbiz/trunk/specialpurpose/pos: config/ screens/default/dialog/ screens/default/menu/ src/org/ofbiz/pos/ src/org/ofbiz/pos/event/ src/org/ofbiz/pos/screen/

lektran
Author: lektran
Date: Wed Nov 14 23:36:14 2007
New Revision: 595231

URL: http://svn.apache.org/viewvc?rev=595231&view=rev
Log:
You can now enter a promo code to be applied to the current sale in pos via the promo menu

Added:
    ofbiz/trunk/specialpurpose/pos/screens/default/dialog/promocode.xml   (with props)
    ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/event/PromoEvents.java   (with props)
    ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/screen/PromoCode.java   (with props)
Modified:
    ofbiz/trunk/specialpurpose/pos/config/XuiLabels.properties
    ofbiz/trunk/specialpurpose/pos/config/buttonevents.xml
    ofbiz/trunk/specialpurpose/pos/config/pos.properties
    ofbiz/trunk/specialpurpose/pos/screens/default/menu/promomain.xml
    ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/PosTransaction.java

Modified: ofbiz/trunk/specialpurpose/pos/config/XuiLabels.properties
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/pos/config/XuiLabels.properties?rev=595231&r1=595230&r2=595231&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/pos/config/XuiLabels.properties (original)
+++ ofbiz/trunk/specialpurpose/pos/config/XuiLabels.properties Wed Nov 14 23:36:14 2007
@@ -43,6 +43,7 @@
 ITEM_DISC=ITEM DISC
 ITEM_MODIFICATION_ERROR=ITEM MODIFICATION ERROR
 LANG=LANG
+LOAD=LOAD
 LOCK=LOCK
 MAIN=MAIN
 MANAGER_NOT_LOGGED_IN=MANAGER NOT LOGGED IN
@@ -58,6 +59,7 @@
 PAY=PAY
 PRINTER_NOT_READY=PRINTER NOT READY
 PROMO=PROMO
+PROMO_CODE=PROMO CODE
 QTY=QTY
 RECEIPT_PRINTER_COMMUNICATION_ERROR=RECEIPT PRINTER COMMUNICATION ERROR
 REPRINT=REPRINT

Modified: ofbiz/trunk/specialpurpose/pos/config/buttonevents.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/pos/config/buttonevents.xml?rev=595231&r1=595230&r2=595231&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/pos/config/buttonevents.xml (original)
+++ ofbiz/trunk/specialpurpose/pos/config/buttonevents.xml Wed Nov 14 23:36:14 2007
@@ -101,6 +101,7 @@
     <event button-name="menuPromo" class-name="org.ofbiz.pos.event.NavagationEvents" method-name="showPromoScreen" disable-lock="false"/>
 
     <!-- pos promo menu events -->
+    <event button-name="promoCode" class-name="org.ofbiz.pos.event.PromoEvents" method-name="promoCode" disable-lock="false"/>
 
     <!-- pos mgr menu events -->
     <event button-name="mgrOpenTerm" class-name="org.ofbiz.pos.event.ManagerEvents" method-name="openTerminal" disable-lock="false"/>

Modified: ofbiz/trunk/specialpurpose/pos/config/pos.properties
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/pos/config/pos.properties?rev=595231&r1=595230&r2=595231&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/pos/config/pos.properties (original)
+++ ofbiz/trunk/specialpurpose/pos/config/pos.properties Wed Nov 14 23:36:14 2007
@@ -44,6 +44,7 @@
 ISOPEN=Register Is Open
 ITEM=ITEM
 Invalid_Selection=Invalid Selection!
+LoadAPromoCode=Load a promotion code
 LoadASale=Load a sale
 LoadSaleListDblClickTip=You may use a double click to replace the current sale and delete this one
 OPDRAM=Starting Drawer Amount:

Added: ofbiz/trunk/specialpurpose/pos/screens/default/dialog/promocode.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/pos/screens/default/dialog/promocode.xml?rev=595231&view=auto
==============================================================================
--- ofbiz/trunk/specialpurpose/pos/screens/default/dialog/promocode.xml (added)
+++ ofbiz/trunk/specialpurpose/pos/screens/default/dialog/promocode.xml Wed Nov 14 23:36:14 2007
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you 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="org.ofbiz.pos.screen.XFocusDialog"-->
+<XPage class="net.xoetrope.swing.XDialog">    
+    <Components>
+        <Panel name="promoCodePanel" x="0" y="0" w="680" h="144" style="menu">
+            <Edit name="codeEdit"  x="20" y="20" w="400" h="44" style="input"/>
+            <Button name="BtnCancel" x="460" y="80" w="180" h="44" content="Cancel" style="dialogButton"/>
+            <Button name="BtnLoad" x="460" y="20" w="180" h="44" content="Load" style="dialogButton"/>
+        </Panel>
+    </Components>
+</XPage>
\ No newline at end of file

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

Propchange: ofbiz/trunk/specialpurpose/pos/screens/default/dialog/promocode.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: ofbiz/trunk/specialpurpose/pos/screens/default/menu/promomain.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/pos/screens/default/menu/promomain.xml?rev=595231&r1=595230&r2=595231&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/pos/screens/default/menu/promomain.xml (original)
+++ ofbiz/trunk/specialpurpose/pos/screens/default/menu/promomain.xml Wed Nov 14 23:36:14 2007
@@ -26,6 +26,6 @@
         <Button name="" x="408" y="0" w="100" h="60" style="posButton" content="" alignment="Center"/>
         <Button name="menuPay" x="510" y="0" w="100" h="60" style="posButton" content="PAY" alignment="Center"/>
               
-        <Label x="0" y="200" w="600" h="50" name="promoLabel" style="input" content="promo_page" alignment="center"/>
+        <Button name="promoCode" x="0" y="62" w="100" h="60" style="posButton" content="PROMO_CODE" alignment="Center"/>
     </Components>    
 </XPage>

Modified: ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/PosTransaction.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/PosTransaction.java?rev=595231&r1=595230&r2=595231&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/PosTransaction.java (original)
+++ ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/PosTransaction.java Wed Nov 14 23:36:14 2007
@@ -1049,4 +1049,9 @@
             pos.showDialog("dialog/error/exception", UtilProperties.getMessage("OrderErrorUiLabels", "OrderUnableToCreateNewShoppingList",locale));
         }
     }
+
+    public String addProductPromoCode(String code, PosScreen pos) {
+        LocalDispatcher dispatcher = session.getDispatcher();
+        return cart.addProductPromoCode(code, dispatcher);
+    }
 }

Added: ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/event/PromoEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/event/PromoEvents.java?rev=595231&view=auto
==============================================================================
--- ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/event/PromoEvents.java (added)
+++ ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/event/PromoEvents.java Wed Nov 14 23:36:14 2007
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.event;
+
+import java.util.List;
+import java.util.HashMap;
+import java.util.Map;
+import java.sql.Timestamp;
+import java.util.Locale;
+import java.text.DecimalFormat;
+import java.text.ParseException;
+
+import net.xoetrope.xui.XProjectManager;
+
+import org.ofbiz.base.util.cache.UtilCache;
+import org.ofbiz.base.util.Debug;
+import org.ofbiz.base.util.UtilMisc;
+import org.ofbiz.base.util.UtilDateTime;
+import org.ofbiz.base.util.UtilFormatOut;
+import org.ofbiz.base.util.UtilValidate;
+import org.ofbiz.pos.device.DeviceLoader;
+import org.ofbiz.pos.device.impl.Receipt;
+import org.ofbiz.pos.screen.PosScreen;
+import org.ofbiz.pos.screen.PaidInOut;
+import org.ofbiz.pos.screen.PromoCode;
+import org.ofbiz.pos.PosTransaction;
+import org.ofbiz.pos.adaptor.SyncCallbackAdaptor;
+import org.ofbiz.pos.component.Input;
+import org.ofbiz.pos.component.Output;
+import org.ofbiz.entity.GenericDelegator;
+import org.ofbiz.entity.GenericEntityException;
+import org.ofbiz.entity.GenericValue;
+import org.ofbiz.entity.util.EntityListIterator;
+import org.ofbiz.entity.condition.EntityExpr;
+import org.ofbiz.entity.condition.EntityOperator;
+import org.ofbiz.entity.condition.EntityConditionList;
+import org.ofbiz.service.LocalDispatcher;
+import org.ofbiz.service.GenericServiceException;
+import org.ofbiz.service.ServiceUtil;
+import org.ofbiz.guiapp.xui.XuiSession;
+import org.ofbiz.base.util.UtilProperties;
+
+public class PromoEvents {
+
+    public static final String module = PromoEvents.class.getName();
+
+    public static void promoCode(PosScreen pos) {
+        
+        PosTransaction trans = PosTransaction.getCurrentTx(pos.getSession());
+        if (!trans.isOpen()) {
+            pos.showDialog("dialog/error/terminalclosed");
+            return;
+        }
+        
+        PromoCode promoCode = new PromoCode(trans, pos);
+        promoCode.openDlg();
+        if (promoCode.isPromoLoaded()) {
+            NavagationEvents.showPosScreen(pos);
+        }
+    }    
+}

Propchange: ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/event/PromoEvents.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/event/PromoEvents.java
------------------------------------------------------------------------------
    svn:keywords = "Date Rev Author URL Id"

Propchange: ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/event/PromoEvents.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/screen/PromoCode.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/screen/PromoCode.java?rev=595231&view=auto
==============================================================================
--- ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/screen/PromoCode.java (added)
+++ ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/screen/PromoCode.java Wed Nov 14 23:36:14 2007
@@ -0,0 +1,126 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.awt.event.ComponentEvent;
+import java.awt.event.ComponentListener;
+import java.awt.event.ContainerListener;
+import java.awt.event.FocusEvent;
+import java.awt.event.FocusListener;
+import java.util.Locale;
+
+import net.xoetrope.swing.XButton;
+import net.xoetrope.swing.XDialog;
+import net.xoetrope.swing.XEdit;
+import net.xoetrope.xui.XPage;
+
+import org.ofbiz.base.util.Debug;
+import org.ofbiz.base.util.UtilProperties;
+import org.ofbiz.base.util.UtilValidate;
+import org.ofbiz.pos.PosTransaction;
+
+
+public class PromoCode extends XPage {
+
+    public static final String module = PromoCode.class.getName();
+    protected static PosScreen m_pos = null;
+    protected XDialog m_dialog = null;
+    protected XEdit m_codeEdit = null;
+    protected XButton m_cancel = null;
+    protected XButton m_load = null;
+    protected static PosTransaction m_trans = null;
+    private boolean promoLoaded = false;
+
+    public PromoCode(PosTransaction trans, PosScreen page) {
+        m_trans = trans;
+        m_pos = page;
+    }
+
+    public void openDlg() {
+        m_dialog = (XDialog) pageMgr.loadPage(m_pos.getScreenLocation() + "/dialog/promocode");
+        m_dialog.setCaption(UtilProperties.getMessage("pos", "LoadAPromoCode", Locale.getDefault()));
+        m_codeEdit = (XEdit) m_dialog.findComponent("codeEdit");
+        m_cancel = (XButton) m_dialog.findComponent("BtnCancel");
+        m_load = (XButton) m_dialog.findComponent("BtnLoad");
+        addMouseHandler(m_cancel, "cancel");
+        addMouseHandler(m_load, "loadPromoCode");
+        promoLoaded = false;
+
+        m_dialog.pack();
+
+        m_dialog.showDialog(this);
+    }
+
+    public synchronized void cancel() {
+        if (this.wasMouseClicked()) {
+            m_codeEdit.setText(null);
+            closeDlg();
+        }
+    }
+
+    public synchronized void loadPromoCode() {
+        if (wasMouseClicked()) {
+            String code = this.m_codeEdit.getText();
+            if (UtilValidate.isNotEmpty(code)) {
+                String response = addProductPromoCode(code);
+                if (response != null) {
+                    Debug.logError(response, module);
+                    m_pos.showDialog("dialog/error/exception", response);
+                } else {
+                    promoLoaded = true;
+                }
+                this.m_codeEdit.setText(null);
+                closeDlg();
+            }
+        }
+    }
+
+    private String addProductPromoCode(String code) {
+        final ClassLoader cl = this.getClassLoader(m_pos);
+        Thread.currentThread().setContextClassLoader(cl);
+        return m_trans.addProductPromoCode(code, m_pos);
+    }
+
+    private ClassLoader getClassLoader(PosScreen pos) {
+        ClassLoader cl = pos.getClassLoader();
+        if (cl == null) {
+            try {
+                cl = Thread.currentThread().getContextClassLoader();
+            } catch (Throwable t) {
+            }
+            if (cl == null) {
+                Debug.log("No context classloader available; using class classloader", module);
+                try {
+                    cl = this.getClass().getClassLoader();
+                } catch (Throwable t) {
+                    Debug.logError(t, module);
+                }
+            }
+        }
+        return cl;
+    }    
+
+    private void closeDlg() {
+        m_dialog.closeDlg();
+    }
+    
+    public boolean isPromoLoaded() {
+        return promoLoaded;
+    }
+}
\ No newline at end of file

Propchange: ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/screen/PromoCode.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

Propchange: ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/screen/PromoCode.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain