Added: ofbiz/trunk/specialpurpose/webpos/servicedef/services_search.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/webpos/servicedef/services_search.xml?rev=1125951&view=auto ============================================================================== --- ofbiz/trunk/specialpurpose/webpos/servicedef/services_search.xml (added) +++ ofbiz/trunk/specialpurpose/webpos/servicedef/services_search.xml Sun May 22 13:11:17 2011 @@ -0,0 +1,46 @@ +<?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. +--> +<services xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/services.xsd"> + <description>Web Pos Search Services</description> + <vendor>OFBiz</vendor> + <version>1.0</version> + + <service name="findProducts" engine="java" + location="org.ofbiz.webpos.search.WebPosSearch" invoke="findProducts"> + <description>Find products by name/description/good identification value</description> + <attribute type="String" mode="IN" name="searchByProductIdValue" optional="true"/> + <attribute type="String" mode="IN" name="searchByProductName" optional="true"/> + <attribute type="String" mode="IN" name="searchByProductDescription" optional="true"/> + <attribute type="String" mode="IN" name="goodIdentificationTypeId" optional="true"/> + <attribute type="java.util.List" mode="OUT" name="productsList" optional="true"/> + </service> + + <service name="findParties" engine="java" + location="org.ofbiz.webpos.search.WebPosSearch" invoke="findParties"> + <description>Find parties by name/surname/good identification value</description> + <attribute type="String" mode="IN" name="searchByPartyLastName" optional="true"/> + <attribute type="String" mode="IN" name="searchByPartyFirstName" optional="true"/> + <attribute type="String" mode="IN" name="searchByPartyIdValue" optional="true"/> + <attribute type="String" mode="IN" name="partyIdentificationTypeId" optional="true"/> + <attribute type="String" mode="IN" name="billingLocation" optional="false"/> + <attribute type="String" mode="IN" name="shippingLocation" optional="false"/> + <attribute type="java.util.List" mode="OUT" name="partiesList" optional="true"/> + </service> +</services> Propchange: ofbiz/trunk/specialpurpose/webpos/servicedef/services_search.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/specialpurpose/webpos/servicedef/services_search.xml ------------------------------------------------------------------------------ svn:keywords = Date Rev Author URL Id Propchange: ofbiz/trunk/specialpurpose/webpos/servicedef/services_search.xml ------------------------------------------------------------------------------ svn:mime-type = text/xml Modified: ofbiz/trunk/specialpurpose/webpos/src/org/ofbiz/webpos/WebPosEvents.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/webpos/src/org/ofbiz/webpos/WebPosEvents.java?rev=1125951&r1=1125950&r2=1125951&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/webpos/src/org/ofbiz/webpos/WebPosEvents.java (original) +++ ofbiz/trunk/specialpurpose/webpos/src/org/ofbiz/webpos/WebPosEvents.java Sun May 22 13:11:17 2011 @@ -18,17 +18,32 @@ *******************************************************************************/ package org.ofbiz.webpos; +import java.util.List; +import java.util.Map; +import java.util.Set; + import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; +import javolution.util.FastList; +import javolution.util.FastMap; + +import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.GeneralException; +import org.ofbiz.base.util.UtilGenerics; +import org.ofbiz.base.util.UtilMisc; import org.ofbiz.base.util.UtilValidate; import org.ofbiz.entity.Delegator; +import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; import org.ofbiz.order.shoppingcart.ShoppingCart; +import org.ofbiz.order.shoppingcart.ShoppingCartEvents; +import org.ofbiz.order.shoppinglist.ShoppingListEvents; +import org.ofbiz.product.product.ProductWorker; import org.ofbiz.product.store.ProductStoreWorker; import org.ofbiz.securityext.login.LoginEvents; +import org.ofbiz.service.GenericServiceException; import org.ofbiz.service.LocalDispatcher; import org.ofbiz.webpos.session.WebPosSession; @@ -37,16 +52,18 @@ public class WebPosEvents { public static String module = WebPosEvents.class.getName(); public static String posLogin(HttpServletRequest request, HttpServletResponse response) { + HttpSession session = request.getSession(true); + + // get the posTerminalId + String posTerminalId = (String) request.getParameter("posTerminalId"); + session.removeAttribute("shoppingCart"); + session.removeAttribute("webPosSession"); + WebPosSession webPosSession = WebPosEvents.getWebPosSession(request, posTerminalId); String responseString = LoginEvents.storeLogin(request, response); - - if ("success".equals(responseString)) { - HttpSession session = request.getSession(true); - - // get the posTerminalId - String posTerminalId = request.getParameter("posTerminalId"); - session.removeAttribute("shoppingCart"); - session.removeAttribute("webPosSession"); - WebPosEvents.getWebPosSession(request, posTerminalId); + GenericValue userLoginNew = (GenericValue)session.getAttribute("userLogin"); + + if (UtilValidate.isNotEmpty(userLoginNew) && UtilValidate.isNotEmpty(posTerminalId)) { + webPosSession.setUserLogin(userLoginNew); } return responseString; } @@ -61,6 +78,7 @@ public class WebPosEvents { } return responseString; } + public static WebPosSession getWebPosSession(HttpServletRequest request, String posTerminalId) { HttpSession session = request.getSession(true); GenericValue userLogin = (GenericValue) session.getAttribute("userLogin"); @@ -81,17 +99,22 @@ public class WebPosEvents { currencyUomId = productStore.getString("defaultCurrencyUomId"); } } + + if (UtilValidate.isNotEmpty(userLogin)) { + session.setAttribute("userLogin", userLogin); + } if (UtilValidate.isEmpty(cart)) { cart = new ShoppingCart(delegator, productStoreId, request.getLocale(), currencyUomId); session.setAttribute("shoppingCart", cart); - } if (UtilValidate.isNotEmpty(posTerminalId)) { webPosSession = new WebPosSession(posTerminalId, null, userLogin, request.getLocale(), productStoreId, facilityId, currencyUomId, delegator, dispatcher, cart); session.setAttribute("webPosSession", webPosSession); - } + } else { + Debug.logError("PosTerminalId is empty cannot create a webPosSession", module); + } } return webPosSession; } @@ -108,9 +131,104 @@ public class WebPosEvents { WebPosSession webPosSession = (WebPosSession) session.getAttribute("webPosSession"); if (UtilValidate.isNotEmpty(webPosSession)) { webPosSession.getCurrentTransaction().processSale(); + emptyCartAndClearAutoSaveList(request, response); String posTerminalId = webPosSession.getId(); removeWebPosSession(request, posTerminalId); } return "success"; } -} + + public static String emptyCartAndClearAutoSaveList(HttpServletRequest request, HttpServletResponse response) throws GeneralException { + HttpSession session = request.getSession(true); + WebPosSession webPosSession = (WebPosSession) session.getAttribute("webPosSession"); + ShoppingCartEvents.clearCart(request, response); + + if (UtilValidate.isNotEmpty(webPosSession)) { + String autoSaveListId = ShoppingListEvents.getAutoSaveListId(webPosSession.getDelegator(), webPosSession.getDispatcher(), null, webPosSession.getUserLogin(), webPosSession.getProductStoreId()); + ShoppingListEvents.clearListInfo(webPosSession.getDelegator(), autoSaveListId); + } + return "success"; + } + + public static String getProductType(HttpServletRequest request, HttpServletResponse response) { + Map<String, Object> featureMap = null; + Map<String, Object> variantTreeMap = null; + Map<String, Object> featureTypes = FastMap.newInstance(); + WebPosSession webPosSession = getWebPosSession(request, null); + if (webPosSession != null) { + Delegator delegator = webPosSession.getDelegator(); + LocalDispatcher dispatcher = webPosSession.getDispatcher(); + GenericValue product = null; + try { + String productId = request.getParameter("productId"); + product = delegator.findOne("Product", false, "productId", productId); + if (UtilValidate.isNotEmpty(product)) { + request.setAttribute("product", product); + if (UtilValidate.isNotEmpty(product.getString("isVirtual")) && "Y".equalsIgnoreCase(product.getString("isVirtual"))) { + String virtualVariantMethodEnum = product.getString("virtualVariantMethodEnum"); + if (UtilValidate.isEmpty(virtualVariantMethodEnum)) { + virtualVariantMethodEnum = "VV_VARIANTTREE"; + } + if ("VV_VARIANTTREE".equalsIgnoreCase(virtualVariantMethodEnum)) { + String productStoreId = webPosSession.getProductStoreId(); + try { + featureMap = dispatcher.runSync("getProductFeatureSet", UtilMisc.toMap("productId", productId)); + Set<String> featureSet = UtilGenerics.cast(featureMap.get("featureSet")); + if (UtilValidate.isNotEmpty(featureSet)) { + request.setAttribute("featureSet", featureSet); + try { + variantTreeMap = dispatcher.runSync("getProductVariantTree", + UtilMisc.toMap("productId", productId, "featureOrder", featureSet, "productStoreId", productStoreId)); + Map<String, Object> variantTree = UtilGenerics.cast(variantTreeMap.get("variantTree")); + if (UtilValidate.isNotEmpty(variantTree)) { + request.setAttribute("variantTree", variantTree); + request.setAttribute("variantTreeSize", variantTree.size()); + List<String> featureOrder = FastList.newInstance(); + featureOrder = UtilMisc.toList(featureSet); + for (int i=0; i < featureOrder.size(); i++) { + String featureKey = (String) featureOrder.get(i); + GenericValue featureValue = delegator.findOne("ProductFeatureType", UtilMisc.toMap("productFeatureTypeId", featureOrder.get(i)), true); + if (UtilValidate.isNotEmpty(featureValue) && + UtilValidate.isNotEmpty(featureValue.get("description"))) { + featureTypes.put(featureKey, featureValue.get("description")); + } else { + featureTypes.put(featureKey, featureValue.get("productFeatureTypeId")); + } + } + request.setAttribute("featureTypes", featureTypes); + request.setAttribute("featureOrder", featureOrder); + if (UtilValidate.isNotEmpty(featureOrder)) { + request.setAttribute("featureOrderFirst", featureOrder.get(0)); + } + } + Map<String, Object> imageMap = UtilGenerics.cast(variantTreeMap.get("variantSample")); + if (UtilValidate.isNotEmpty(imageMap)) { + List<String> variantSampleList = FastList.newInstance(); + variantSampleList = UtilMisc.toList(imageMap.keySet()); + request.setAttribute("variantSample", imageMap); + request.setAttribute("variantSampleList", variantSampleList); + request.setAttribute("variantSampleSize", imageMap.size()); + } + } catch (GenericServiceException e) { + Debug.logError(e, module); + return "error"; + } + } + } catch (GenericServiceException e) { + Debug.logError(e, module); + return "error"; + } + } + if ("VV_FEATURETREE".equalsIgnoreCase(virtualVariantMethodEnum)) { + request.setAttribute("featureLists", ProductWorker.getSelectableProductFeaturesByTypesAndSeq(product)); + } + } + } + } catch (GenericEntityException e) { + Debug.logError(e, module); + return "error"; + } + } + return "success"; + } +} \ No newline at end of file Added: ofbiz/trunk/specialpurpose/webpos/src/org/ofbiz/webpos/search/WebPosSearch.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/webpos/src/org/ofbiz/webpos/search/WebPosSearch.java?rev=1125951&view=auto ============================================================================== --- ofbiz/trunk/specialpurpose/webpos/src/org/ofbiz/webpos/search/WebPosSearch.java (added) +++ ofbiz/trunk/specialpurpose/webpos/src/org/ofbiz/webpos/search/WebPosSearch.java Sun May 22 13:11:17 2011 @@ -0,0 +1,192 @@ +/******************************************************************************* + * 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.webpos.search; + +import java.util.List; +import java.util.Map; + +import javolution.util.FastList; + +import org.ofbiz.base.util.Debug; +import org.ofbiz.base.util.UtilValidate; +import org.ofbiz.entity.Delegator; +import org.ofbiz.entity.GenericEntityException; +import org.ofbiz.entity.GenericValue; +import org.ofbiz.entity.condition.EntityCondition; +import org.ofbiz.entity.condition.EntityFunction; +import org.ofbiz.entity.condition.EntityOperator; +import org.ofbiz.entity.model.DynamicViewEntity; +import org.ofbiz.entity.model.ModelKeyMap; +import org.ofbiz.entity.util.EntityListIterator; +import org.ofbiz.entity.util.EntityUtil; +import org.ofbiz.service.DispatchContext; +import org.ofbiz.service.ServiceUtil; + +public class WebPosSearch { + + public static final String module = WebPosSearch.class.getName(); + + public static Map<String, Object> findProducts(DispatchContext dctx, Map<String, ? extends Object> context) { + Delegator delegator = dctx.getDelegator(); + String searchByProductIdValue = (String) context.get("searchByProductIdValue"); + String searchByProductName = (String) context.get("searchByProductName"); + String searchByProductDescription = (String) context.get("searchByProductDescription"); + String goodIdentificationTypeId = (String) context.get("goodIdentificationTypeId"); + Map<String, Object> result = ServiceUtil.returnSuccess(); + + List<EntityCondition> andExprs = FastList.newInstance(); + EntityCondition mainCond = null; + List<String> orderBy = FastList.newInstance(); + List<String> fieldsToSelect = FastList.newInstance(); + String entityName = "Product"; + + fieldsToSelect.add("productId"); + fieldsToSelect.add("productName"); + fieldsToSelect.add("description"); + orderBy.add("productName"); + orderBy.add("description"); + + // search by product name + if (UtilValidate.isNotEmpty(searchByProductName)) { + searchByProductName = searchByProductName.toUpperCase().trim(); + andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("productName"), EntityOperator.LIKE, EntityFunction.UPPER("%" + searchByProductName + "%"))); + } + // search by description + if (UtilValidate.isNotEmpty(searchByProductDescription)) { + searchByProductDescription = searchByProductDescription.toUpperCase().trim(); + andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("description"), EntityOperator.LIKE, EntityFunction.UPPER("%" + searchByProductDescription + "%"))); + } + // search by good identification + if (UtilValidate.isNotEmpty(searchByProductIdValue)) { + entityName = "GoodIdentificationAndProduct"; + searchByProductIdValue = searchByProductIdValue.toUpperCase().trim(); + andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("idValue"), EntityOperator.EQUALS, searchByProductIdValue)); + if (UtilValidate.isNotEmpty(goodIdentificationTypeId)) { + andExprs.add(EntityCondition.makeCondition("goodIdentificationTypeId", EntityOperator.EQUALS, goodIdentificationTypeId)); + } + } + mainCond = EntityCondition.makeCondition(andExprs, EntityOperator.AND); + List<GenericValue> products = null; + try { + products = delegator.findList(entityName, mainCond, null, orderBy, null, false); + } catch (GenericEntityException e) { + Debug.logError(e, module); + } + result.put("productsList", products); + return result; + } + + public static Map<String, Object> findParties(DispatchContext dctx, Map<String, ? extends Object> context) { + Delegator delegator = dctx.getDelegator(); + String searchByPartyLastName = (String) context.get("searchByPartyLastName"); + String searchByPartyFirstName = (String) context.get("searchByPartyFirstName"); + String searchByPartyIdValue = (String) context.get("searchByPartyIdValue"); + String partyIdentificationTypeId = (String) context.get("partyIdentificationTypeId"); + String billingLocation = (String) context.get("billingLocation"); + String shippingLocation = (String) context.get("shippingLocation"); + Map<String, Object> result = ServiceUtil.returnSuccess(); + + List<EntityCondition> andExprs = FastList.newInstance(); + List<EntityCondition> orExprs = FastList.newInstance(); + EntityCondition mainCond = null; + List<String> orderBy = FastList.newInstance(); + + // default view settings + DynamicViewEntity dynamicView = new DynamicViewEntity(); + dynamicView.addMemberEntity("PT", "Party"); + dynamicView.addAlias("PT", "partyId"); + dynamicView.addAlias("PT", "statusId"); + dynamicView.addAlias("PT", "partyTypeId"); + dynamicView.addMemberEntity("PI", "PartyIdentification"); + dynamicView.addAlias("PI", "partyIdentificationTypeId"); + dynamicView.addAlias("PI", "idValue"); + dynamicView.addViewLink("PT", "PI", Boolean.TRUE, ModelKeyMap.makeKeyMapList("partyId")); + dynamicView.addMemberEntity("PER", "Person"); + dynamicView.addAlias("PER", "lastName"); + dynamicView.addAlias("PER", "firstName"); + dynamicView.addViewLink("PT", "PER", Boolean.TRUE, ModelKeyMap.makeKeyMapList("partyId")); + dynamicView.addMemberEntity("PCP", "PartyContactMechPurpose"); + dynamicView.addAlias("PCP", "contactMechId"); + dynamicView.addAlias("PCP", "contactMechPurposeTypeId"); + dynamicView.addAlias("PCP", "fromDate"); + dynamicView.addAlias("PCP", "thruDate"); + dynamicView.addViewLink("PT", "PCP", Boolean.TRUE, ModelKeyMap.makeKeyMapList("partyId")); + dynamicView.addMemberEntity("CM", "ContactMech"); + dynamicView.addAlias("CM", "contactMechId"); + dynamicView.addAlias("CM", "contactMechTypeId"); + dynamicView.addAlias("CM", "infoString"); + dynamicView.addViewLink("PCP", "CM", Boolean.TRUE, ModelKeyMap.makeKeyMapList("contactMechId")); + dynamicView.addMemberEntity("PA", "PostalAddress"); + dynamicView.addAlias("PA", "address1"); + dynamicView.addAlias("PA", "city"); + dynamicView.addAlias("PA", "postalCode"); + dynamicView.addAlias("PA", "countryGeoId"); + dynamicView.addAlias("PA", "stateProvinceGeoId"); + dynamicView.addViewLink("CM", "PA", Boolean.TRUE, ModelKeyMap.makeKeyMapList("contactMechId")); + + if (UtilValidate.isNotEmpty(billingLocation) && "Y".equalsIgnoreCase(billingLocation)) { + orExprs.add(EntityCondition.makeCondition("contactMechPurposeTypeId", EntityOperator.EQUALS, "BILLING_LOCATION")); + } + + if (UtilValidate.isNotEmpty(shippingLocation) && "Y".equalsIgnoreCase(shippingLocation)) { + orExprs.add(EntityCondition.makeCondition("contactMechPurposeTypeId", EntityOperator.EQUALS, "SHIPPING_LOCATION")); + } + + if (orExprs.size() > 0) { + andExprs.add(EntityCondition.makeCondition(orExprs, EntityOperator.OR)); + } + andExprs.add(EntityCondition.makeCondition("partyTypeId", EntityOperator.EQUALS, "PERSON")); + andExprs.add(EntityCondition.makeCondition("contactMechTypeId", EntityOperator.EQUALS, "POSTAL_ADDRESS")); + + mainCond = EntityCondition.makeCondition(andExprs, EntityOperator.AND); + + orderBy.add("lastName"); + orderBy.add("firstName"); + + // search by last name + if (UtilValidate.isNotEmpty(searchByPartyLastName)) { + searchByPartyLastName = searchByPartyLastName.toUpperCase().trim(); + andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("lastName"), EntityOperator.LIKE, EntityFunction.UPPER("%" + searchByPartyLastName + "%"))); + } + // search by first name + if (UtilValidate.isNotEmpty(searchByPartyFirstName)) { + searchByPartyFirstName = searchByPartyFirstName.toUpperCase().trim(); + andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("firstName"), EntityOperator.LIKE, EntityFunction.UPPER("%" + searchByPartyFirstName + "%"))); + } + // search by party identification + if (UtilValidate.isNotEmpty(searchByPartyIdValue)) { + searchByPartyIdValue = searchByPartyIdValue.toUpperCase().trim(); + andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("idValue"), EntityOperator.EQUALS, searchByPartyIdValue)); + if (UtilValidate.isNotEmpty(partyIdentificationTypeId)) { + andExprs.add(EntityCondition.makeCondition("partyIdentificationTypeId", EntityOperator.EQUALS, partyIdentificationTypeId)); + } + } + mainCond = EntityCondition.makeCondition(andExprs, EntityOperator.AND); + List<GenericValue> parties = null; + try { + EntityListIterator pli = delegator.findListIteratorByCondition(dynamicView, mainCond, null, null, orderBy, null); + parties = EntityUtil.filterByDate(pli.getCompleteList(), true); + pli.close(); + } catch (GenericEntityException e) { + Debug.logError(e, module); + } + result.put("partiesList", parties); + return result; + } +} \ No newline at end of file Propchange: ofbiz/trunk/specialpurpose/webpos/src/org/ofbiz/webpos/search/WebPosSearch.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/specialpurpose/webpos/src/org/ofbiz/webpos/search/WebPosSearch.java ------------------------------------------------------------------------------ svn:keywords = Date Rev Author URL Id Propchange: ofbiz/trunk/specialpurpose/webpos/src/org/ofbiz/webpos/search/WebPosSearch.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Modified: ofbiz/trunk/specialpurpose/webpos/src/org/ofbiz/webpos/session/WebPosSession.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/webpos/src/org/ofbiz/webpos/session/WebPosSession.java?rev=1125951&r1=1125950&r2=1125951&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/webpos/src/org/ofbiz/webpos/session/WebPosSession.java (original) +++ ofbiz/trunk/specialpurpose/webpos/src/org/ofbiz/webpos/session/WebPosSession.java Sun May 22 13:11:17 2011 @@ -66,8 +66,7 @@ public class WebPosSession { this.facilityId = facilityId; this.currencyUomId = currencyUomId; - if (UtilValidate.isNotEmpty(delegator)) - { + if (UtilValidate.isNotEmpty(delegator)) { this.delegator = delegator; this.delegatorName = delegator.getDelegatorName(); } else { @@ -83,6 +82,10 @@ public class WebPosSession { public GenericValue getUserLogin() { return this.userLogin; } + + public void setUserLogin(GenericValue userLogin) { + this.userLogin = userLogin; + } public void setAttribute(String name, Object value) { this.attributes.put(name, value); Modified: ofbiz/trunk/specialpurpose/webpos/src/org/ofbiz/webpos/transaction/WebPosTransaction.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/webpos/src/org/ofbiz/webpos/transaction/WebPosTransaction.java?rev=1125951&r1=1125950&r2=1125951&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/webpos/src/org/ofbiz/webpos/transaction/WebPosTransaction.java (original) +++ ofbiz/trunk/specialpurpose/webpos/src/org/ofbiz/webpos/transaction/WebPosTransaction.java Sun May 22 13:11:17 2011 @@ -28,7 +28,9 @@ import javolution.util.FastMap; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.GeneralException; import org.ofbiz.base.util.UtilDateTime; +import org.ofbiz.base.util.UtilGenerics; import org.ofbiz.base.util.UtilMisc; +import org.ofbiz.base.util.UtilProperties; import org.ofbiz.base.util.UtilValidate; import org.ofbiz.entity.Delegator; import org.ofbiz.entity.GenericEntityException; @@ -37,8 +39,8 @@ import org.ofbiz.entity.condition.Entity import org.ofbiz.entity.util.EntityUtil; import org.ofbiz.order.shoppingcart.CheckOutHelper; import org.ofbiz.order.shoppingcart.ShoppingCart; -import org.ofbiz.order.shoppingcart.ShoppingCart.CartPaymentInfo; import org.ofbiz.order.shoppingcart.ShoppingCartItem; +import org.ofbiz.order.shoppingcart.ShoppingCart.CartPaymentInfo; import org.ofbiz.product.store.ProductStoreWorker; import org.ofbiz.service.GenericServiceException; import org.ofbiz.service.LocalDispatcher; @@ -121,11 +123,12 @@ public class WebPosTransaction { } public boolean isOpen() { + this.isOpen = false; GenericValue terminalState = this.getTerminalState(); if (terminalState != null) { - this.isOpen = true; - } else { - this.isOpen = false; + if ((terminalState.getDate("closedDate")) == null) { + this.isOpen = true; + } } return this.isOpen; } @@ -171,13 +174,13 @@ public class WebPosTransaction { } } - public void modifyPrice(String productId, BigDecimal price) { - Debug.logInfo("Modify item price " + productId + "/" + price, module); - ShoppingCartItem item = getCart().findCartItem(productId, null, null, null, BigDecimal.ZERO); + public void modifyPrice(int cartLineIdx, BigDecimal price) { + ShoppingCartItem item = getCart().findCartItem(cartLineIdx); if (UtilValidate.isNotEmpty(item)) { + Debug.logInfo("Modify item price " + item.getProductId() + "/" + price, module); item.setBasePrice(price); } else { - Debug.logInfo("Item not found " + productId, module); + Debug.logInfo("Item " + cartLineIdx + " not found", module); } } @@ -190,12 +193,11 @@ public class WebPosTransaction { } public BigDecimal processSale() throws GeneralException { - //TODO insert check if not enough funds - Debug.log("process sale", module); + Debug.log("Process sale", module); BigDecimal grandTotal = this.getGrandTotal(); BigDecimal paymentAmt = this.getPaymentTotal(); if (grandTotal.compareTo(paymentAmt) > 0) { - throw new IllegalStateException(); + throw new GeneralException(UtilProperties.getMessage(resource, "WebPosNotEnoughFunds", webPosSession.getLocale())); } // attach the party ID to the cart @@ -203,14 +205,14 @@ public class WebPosTransaction { // validate payment methods Debug.log("Validating payment methods", module); - Map<String, ? extends Object> valRes = ch.validatePaymentMethods(); + Map<String, ? extends Object> valRes = UtilGenerics.cast(ch.validatePaymentMethods()); if (valRes != null && ServiceUtil.isError(valRes)) { throw new GeneralException(ServiceUtil.getErrorMessage(valRes)); } - // store the "order" + // store the order Debug.log("Store order", module); - Map<String, ? extends Object> orderRes = ch.createOrder(webPosSession.getUserLogin()); + Map<String, ? extends Object> orderRes = UtilGenerics.cast(ch.createOrder(webPosSession.getUserLogin())); if (orderRes != null && ServiceUtil.isError(orderRes)) { throw new GeneralException(ServiceUtil.getErrorMessage(orderRes)); @@ -222,7 +224,7 @@ public class WebPosTransaction { Debug.log("Processing the payment(s)", module); Map<String, ? extends Object> payRes = null; try { - payRes = ch.processPayment(ProductStoreWorker.getProductStore(webPosSession.getProductStoreId(), webPosSession.getDelegator()), webPosSession.getUserLogin(), true); + payRes = UtilGenerics.cast(ch.processPayment(ProductStoreWorker.getProductStore(webPosSession.getProductStoreId(), webPosSession.getDelegator()), webPosSession.getUserLogin(), true)); } catch (GeneralException e) { Debug.logError(e, module); throw e; @@ -327,7 +329,7 @@ public class WebPosTransaction { boolean isExternal = true; Iterator<GenericValue> i = values.iterator(); while (i.hasNext() && isExternal) { - GenericValue v = i.next(); + GenericValue v = (GenericValue) i.next(); //Debug.log("Testing [" + paymentMethodTypeId + "] - " + v, module); if (!externalCode.equals(v.getString("paymentServiceTypeEnumId"))) { isExternal = false; @@ -368,16 +370,8 @@ public class WebPosTransaction { return this.getTotalDue(); } - public BigDecimal processAmount(String amtStr) throws GeneralException { - BigDecimal amount; - if (UtilValidate.isNotEmpty(amtStr)) { - try { - amount = new BigDecimal(amtStr); - } catch (NumberFormatException e) { - Debug.logError("Invalid number for amount : " + amtStr, module); - throw new GeneralException(); - } - } else { + public BigDecimal processAmount(BigDecimal amount) throws GeneralException { + if (UtilValidate.isEmpty(amount)) { Debug.log("Amount is empty; assumption is full amount : " + this.getTotalDue(), module); amount = this.getTotalDue(); if (amount.compareTo(BigDecimal.ZERO) <= 0) { @@ -399,14 +393,14 @@ public class WebPosTransaction { } } - public synchronized void processExternalPayment(String paymentMethodTypeId, String amountStr, String refNum) { + public synchronized void processExternalPayment(String paymentMethodTypeId, BigDecimal amount, String refNum) { if (refNum == null) { //TODO handle error message return; } try { - BigDecimal amount = processAmount(amountStr); + amount = processAmount(amount); Debug.log("Processing [" + paymentMethodTypeId + "] Amount : " + amount, module); // add the payment @@ -498,6 +492,10 @@ public class WebPosTransaction { public BigDecimal getPaymentTotal() { return getCart().getPaymentTotal(); } + + public BigDecimal getTotalQuantity() { + return getCart().getTotalQuantity(); + } public BigDecimal getTotalDue() { BigDecimal grandTotal = this.getGrandTotal(); @@ -514,4 +512,4 @@ public class WebPosTransaction { public ShoppingCart getCart() { return webPosSession.getCart(); } -} +} \ No newline at end of file Modified: ofbiz/trunk/specialpurpose/webpos/webapp/webpos/Login.ftl URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/webpos/webapp/webpos/Login.ftl?rev=1125951&r1=1125950&r2=1125951&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/webpos/webapp/webpos/Login.ftl (original) +++ ofbiz/trunk/specialpurpose/webpos/webapp/webpos/Login.ftl Sun May 22 13:11:17 2011 @@ -65,6 +65,8 @@ under the License. </tr> </table> <input type="hidden" name="JavaScriptEnabled" value="N"/> + <br/> + <a href="<@ofbizUrl>forgotPassword</@ofbizUrl>">${uiLabelMap.CommonForgotYourPassword}?</a> </form> </div> </div> Modified: ofbiz/trunk/specialpurpose/webpos/webapp/webpos/RequirePasswordChange.ftl URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/webpos/webapp/webpos/RequirePasswordChange.ftl?rev=1125951&r1=1125950&r2=1125951&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/webpos/webapp/webpos/RequirePasswordChange.ftl (original) +++ ofbiz/trunk/specialpurpose/webpos/webapp/webpos/RequirePasswordChange.ftl Sun May 22 13:11:17 2011 @@ -16,48 +16,45 @@ KIND, either express or implied. See th specific language governing permissions and limitations under the License. --> - <#assign username = ""/> <#if requestParameters.USERNAME?has_content> <#assign username = requestParameters.USERNAME/> <#elseif autoUserLogin?has_content> <#assign username = autoUserLogin.userLoginId/> </#if> - <h1>${uiLabelMap.CommonLogin}</h1> <br /> - <div style="float: center; width: 49%; margin-right: 5px; text-align: center;" class="screenlet"> - <div class="screenlet-title-bar">${uiLabelMap.CommonPasswordChange}</div> - <div class="screenlet-body" style="text-align: center;"> - <form method="post" action="<@ofbizUrl>login${previousParams}</@ofbizUrl>" name="loginform"> - <input type="hidden" name="requirePasswordChange" value="Y"/> - <input type="hidden" name="USERNAME" value="${username}"/> - <div> - ${uiLabelMap.CommonUsername}: ${username} - </div> - <#if autoUserLogin?has_content> - <div> - (${uiLabelMap.CommonNot} ${autoUserLogin.userLoginId}? <a href="<@ofbizUrl>${autoLogoutUrl}</@ofbizUrl>" class="buttontext">${uiLabelMap.CommonClickHere}</a>) - </div> - </#if> - <div class="tabletext"> - ${uiLabelMap.CommonPassword}: - <input type="password" name="PASSWORD" value="" size="20"/> - </div> - <div class="tabletext"> - ${uiLabelMap.CommonNewPassword}: - <input type="password" name="newPassword" value="" size="20"/> - </div> - <div class="tabletext"> - ${uiLabelMap.CommonNewPasswordVerify}: - <input type="password" name="newPasswordVerify" value="" size="20"/> - </div> - <div class="tabletext"> - <input type="submit" class="smallSubmit" value="${uiLabelMap.CommonLogin}"/> - </div> - </form> - </div> + <div class="screenlet-title-bar">${uiLabelMap.CommonPasswordChange}</div> + <div class="screenlet-body" style="text-align: center;"> + <form method="post" action="<@ofbizUrl>login${previousParams}</@ofbizUrl>" name="loginform"> + <input type="hidden" name="requirePasswordChange" value="Y"/> + <input type="hidden" name="USERNAME" value="${username}"/> + <div> + ${uiLabelMap.CommonUsername}: ${username} + </div> + <#if autoUserLogin?has_content> + <div> + (${uiLabelMap.CommonNot} ${autoUserLogin.userLoginId}? <a href="<@ofbizUrl>${autoLogoutUrl}</@ofbizUrl>" class="buttontext">${uiLabelMap.CommonClickHere}</a>) + </div> + </#if> + <div class="tabletext"> + ${uiLabelMap.CommonPassword}: + <input type="password" name="PASSWORD" value="" size="20"/> + </div> + <div class="tabletext"> + ${uiLabelMap.CommonNewPassword}: + <input type="password" name="newPassword" value="" size="20"/> + </div> + <div class="tabletext"> + ${uiLabelMap.CommonNewPasswordVerify}: + <input type="password" name="newPasswordVerify" value="" size="20"/> + </div> + <div class="tabletext"> + <input type="submit" class="smallSubmit" value="${uiLabelMap.CommonLogin}"/> + </div> + </form> + </div> </div> <script language="JavaScript" type="text/javascript"> Modified: ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/buttons/Main.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/buttons/Main.groovy?rev=1125951&r1=1125950&r2=1125951&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/buttons/Main.groovy (original) +++ ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/buttons/Main.groovy Sun May 22 13:11:17 2011 @@ -1,35 +0,0 @@ -/* - * 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. - */ - -import org.ofbiz.webpos.WebPosEvents; -import org.ofbiz.webpos.session.WebPosSession; -import org.ofbiz.webpos.transaction.WebPosTransaction; - -webPosSession = WebPosEvents.getWebPosSession(request, null); -if (webPosSession) { - context.shoppingCartSize = webPosSession.getCart().size(); - context.isManagerLoggedIn = webPosSession.isManagerLoggedIn(); - webPosTransaction = webPosSession.getCurrentTransaction(); - - if (webPosTransaction) { - context.isOpen = webPosTransaction.isOpen(); - } -} else { - context.shoppingCartSize = 0; -} Modified: ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/buttons/Payment.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/buttons/Payment.groovy?rev=1125951&r1=1125950&r2=1125951&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/buttons/Payment.groovy (original) +++ ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/buttons/Payment.groovy Sun May 22 13:11:17 2011 @@ -1,33 +0,0 @@ -/* - * 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. - */ - -import org.ofbiz.webpos.WebPosEvents; -import org.ofbiz.webpos.session.WebPosSession; - -webPosSession = WebPosEvents.getWebPosSession(request, null); -if (webPosSession) { - context.cart = webPosSession.getCart(); - - if (context.cart) { - context.shoppingCartSize = context.cart.size(); - } - - context.totalDue = webPosSession.getCurrentTransaction().getTotalDue(); - context.totalPayments = webPosSession.getCurrentTransaction().getPaymentTotal(); -} Modified: ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/cart/MicroCart.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/cart/MicroCart.groovy?rev=1125951&r1=1125950&r2=1125951&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/cart/MicroCart.groovy (original) +++ ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/cart/MicroCart.groovy Sun May 22 13:11:17 2011 @@ -1,80 +0,0 @@ -/* - * 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. - */ - -import org.ofbiz.base.util.UtilProperties; -import org.ofbiz.webpos.WebPosEvents; -import org.ofbiz.webpos.session.WebPosSession; -import org.ofbiz.webpos.transaction.WebPosTransaction; -import java.text.SimpleDateFormat; - -webPosSession = WebPosEvents.getWebPosSession(request, null); -if (webPosSession) { - shoppingCart = webPosSession.getCart(); - context.transactionId = webPosSession.getCurrentTransaction().getTransactionId(); - context.userLoginId = webPosSession.getUserLoginId(); - context.drawerNumber = webPosSession.getCurrentTransaction().getDrawerNumber(); - sdf = new SimpleDateFormat(UtilProperties.getMessage(WebPosTransaction.resource, "WebPosTransactionDateFormat", Locale.getDefault())); - context.transactionDate = sdf.format(new Date()); - context.totalDue = webPosSession.getCurrentTransaction().getTotalDue(); -} else { - shoppingCart = null; -} - -context.cashAmount = BigDecimal.ZERO; -context.checkAmount = BigDecimal.ZERO; -context.giftAmount = BigDecimal.ZERO; -context.creditAmount = BigDecimal.ZERO; - -// Get the Cart and Prepare Size -if (shoppingCart) { - context.shoppingCartSize = shoppingCart.size(); - payments = shoppingCart.selectedPayments(); - for (i = 0; i < payments; i++) { - paymentInfo = shoppingCart.getPaymentInfo(i); - if (paymentInfo.amount != null) { - amount = paymentInfo.amount; - if (paymentInfo.paymentMethodTypeId != null) { - if ("CASH".equals(paymentInfo.paymentMethodTypeId)) { - context.cashAmount = new BigDecimal((context.cashAmount).add(amount)); - } - else if ("PERSONAL_CHECK".equals(paymentInfo.paymentMethodTypeId)) { - context.checkAmount = new BigDecimal((context.checkAmount).add(amount)); - requestParameters.refNumCheck = paymentInfo.refNum[0]; - } - else if ("GIFT_CARD".equals(paymentInfo.paymentMethodTypeId)) { - context.giftAmount = new BigDecimal((context.giftAmount).add(amount)); - requestParameters.refNumGift = paymentInfo.refNum[0]; - } - else if ("CREDIT_CARD".equals(paymentInfo.paymentMethodTypeId)) { - context.creditAmount = new BigDecimal((context.creditAmount).add(amount)); - requestParameters.refNumCredit = paymentInfo.refNum[0]; - print("paymentInfo "+paymentInfo); - } - } - } - } - context.shoppingCart = shoppingCart; -} else { - context.shoppingCartSize = 0; -} - -context.paymentCash = delegator.findOne("PaymentMethodType", ["paymentMethodTypeId" : "CASH"], true); -context.paymentCheck = delegator.findOne("PaymentMethodType", ["paymentMethodTypeId" : "PERSONAL_CHECK"], true); -context.paymentGift = delegator.findOne("PaymentMethodType", ["paymentMethodTypeId" : "GIFT_CARD"], true); -context.paymentCredit = delegator.findOne("PaymentMethodType", ["paymentMethodTypeId" : "CREDIT_CARD"], true); Modified: ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/cart/ShowCart.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/cart/ShowCart.groovy?rev=1125951&r1=1125950&r2=1125951&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/cart/ShowCart.groovy (original) +++ ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/cart/ShowCart.groovy Sun May 22 13:11:17 2011 @@ -16,28 +16,70 @@ * specific language governing permissions and limitations * under the License. */ - +import org.ofbiz.base.util.UtilProperties; +import org.ofbiz.base.util.UtilValidate; import org.ofbiz.webpos.WebPosEvents; import org.ofbiz.webpos.session.WebPosSession; +import org.ofbiz.webpos.transaction.WebPosTransaction; webPosSession = WebPosEvents.getWebPosSession(request, null); if (webPosSession) { shoppingCart = webPosSession.getCart(); + context.isManager = webPosSession.isManagerLoggedIn(); + context.transactionId = webPosSession.getCurrentTransaction().getTransactionId(); + context.userLoginId = webPosSession.getUserLoginId(); + context.drawerNumber = webPosSession.getCurrentTransaction().getDrawerNumber(); + context.totalDue = webPosSession.getCurrentTransaction().getTotalDue(); + context.totalQuantity = webPosSession.getCurrentTransaction().getTotalQuantity(); + context.isOpen = webPosSession.getCurrentTransaction().isOpen(); + + context.person = null; + if (UtilValidate.isNotEmpty(shoppingCart)) { + placingCustomerParty = delegator.findOne("PartyAndPerson", [partyId : shoppingCart.getPlacingCustomerPartyId()], false); + if (UtilValidate.isNotEmpty(placingCustomerParty)) { + context.person = placingCustomerParty.lastName + " " + placingCustomerParty.firstName; + } + } } else { shoppingCart = null; } -// Get the Cart and Prepare Size +context.cashAmount = BigDecimal.ZERO; +context.checkAmount = BigDecimal.ZERO; +context.giftAmount = BigDecimal.ZERO; +context.creditAmount = BigDecimal.ZERO; +context.totalPay = BigDecimal.ZERO; + if (shoppingCart) { context.shoppingCartSize = shoppingCart.size(); + payments = shoppingCart.selectedPayments(); + for (i = 0; i < payments; i++) { + paymentInfo = shoppingCart.getPaymentInfo(i); + if (paymentInfo.amount != null) { + amount = paymentInfo.amount; + if (paymentInfo.paymentMethodTypeId != null) { + if ("CASH".equals(paymentInfo.paymentMethodTypeId)) { + context.cashAmount = new BigDecimal((context.cashAmount).add(amount)); + } + else if ("PERSONAL_CHECK".equals(paymentInfo.paymentMethodTypeId)) { + context.checkAmount = new BigDecimal((context.checkAmount).add(amount)); + } + else if ("GIFT_CARD".equals(paymentInfo.paymentMethodTypeId)) { + context.giftAmount = new BigDecimal((context.giftAmount).add(amount)); + } + else if ("CREDIT_CARD".equals(paymentInfo.paymentMethodTypeId)) { + context.creditAmount = new BigDecimal((context.creditAmount).add(amount)); + } + context.totalPay = new BigDecimal((context.totalPay).add(amount)); + } + } + } + context.shoppingCart = shoppingCart; } else { context.shoppingCartSize = 0; } -context.shoppingCart = shoppingCart; -//check if a parameter is passed -if (request.getAttribute("add_product_id") != "") { - add_product_id = request.getParameter("add_product_id"); - product = delegator.findOne("Product", [productId : add_product_id], true); - context.product = product; -} +context.paymentCash = delegator.findOne("PaymentMethodType", ["paymentMethodTypeId" : "CASH"], true); +context.paymentCheck = delegator.findOne("PaymentMethodType", ["paymentMethodTypeId" : "PERSONAL_CHECK"], true); +context.paymentGift = delegator.findOne("PaymentMethodType", ["paymentMethodTypeId" : "GIFT_CARD"], true); +context.paymentCredit = delegator.findOne("PaymentMethodType", ["paymentMethodTypeId" : "CREDIT_CARD"], true); \ No newline at end of file Added: ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/catalog/Category.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/catalog/Category.groovy?rev=1125951&view=auto ============================================================================== --- ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/catalog/Category.groovy (added) +++ ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/catalog/Category.groovy Sun May 22 13:11:17 2011 @@ -0,0 +1,65 @@ +/* + * 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. + */ + +/* + * This script is also referenced by the ecommerce's screens and + * should not contain order component's specific code. + */ + +import org.ofbiz.base.util.*; +import org.ofbiz.entity.*; +import org.ofbiz.product.catalog.*; +import org.ofbiz.product.category.CategoryWorker; +import org.ofbiz.product.category.CategoryContentWrapper; + +detailScreen = "categorydetail"; +catalogName = CatalogWorker.getCatalogName(request); + +productCategoryId = parameters.productCategoryId; +if (!(productCategoryId) && request.getAttribute("topCategoryId")) { + productCategoryId = request.getAttribute("topCategoryId"); +} + +category = delegator.findByPrimaryKeyCache("ProductCategory", [productCategoryId : productCategoryId]); +if (category) { + if (category.detailScreen) { + detailScreen = category.detailScreen; + } + categoryContentWrapper = new CategoryContentWrapper(category, request); + context.title = categoryContentWrapper.CATEGORY_NAME; + categoryDescription = categoryContentWrapper.DESCRIPTION; + if (categoryDescription) { + context.metaDescription = categoryDescription; + context.metaKeywords = categoryDescription + ", " + catalogName; + } else { + context.metaKeywords = catalogName; + } + context.productCategory = category; +} + +// check the catalogs template path and update +templatePathPrefix = CatalogWorker.getTemplatePathPrefix(request); +if (templatePathPrefix) { + detailScreen = templatePathPrefix + detailScreen; +} +context.detailScreen = detailScreen; + +request.setAttribute("productCategoryId", productCategoryId); +request.setAttribute("defaultViewSize", 10); +request.setAttribute("limitView", true); Propchange: ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/catalog/Category.groovy ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/catalog/Category.groovy ------------------------------------------------------------------------------ svn:keywords = Date Rev Author URL Id Propchange: ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/catalog/Category.groovy ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/catalog/CategoryDetail.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/catalog/CategoryDetail.groovy?rev=1125951&view=auto ============================================================================== --- ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/catalog/CategoryDetail.groovy (added) +++ ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/catalog/CategoryDetail.groovy Sun May 22 13:11:17 2011 @@ -0,0 +1,115 @@ +/* + * 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. + */ +import org.ofbiz.base.util.*; +import org.ofbiz.entity.*; +import org.ofbiz.service.*; +import org.ofbiz.product.catalog.*; +import org.ofbiz.product.category.CategoryContentWrapper; +import org.ofbiz.product.store.ProductStoreWorker; + +productCategoryId = request.getAttribute("productCategoryId"); +context.productCategoryId = productCategoryId; + +viewSize = parameters.VIEW_SIZE; +viewIndex = parameters.VIEW_INDEX; +currentCatalogId = CatalogWorker.getCurrentCatalogId(request); + +// set the default view size +defaultViewSize = request.getAttribute("defaultViewSize") ?: 10; +context.defaultViewSize = defaultViewSize; + +// set the limit view +limitView = request.getAttribute("limitView") ?: true; +context.limitView = limitView; + +// get the product category & members +andMap = [productCategoryId : productCategoryId, + viewIndexString : viewIndex, + viewSizeString : viewSize, + defaultViewSize : defaultViewSize, + limitView : limitView]; +andMap.put("prodCatalogId", currentCatalogId); +andMap.put("checkViewAllow", true); +if (context.orderByFields) { + andMap.put("orderByFields", context.orderByFields); +} else { + andMap.put("orderByFields", ["sequenceNum", "productId"]); +} +catResult = dispatcher.runSync("getProductCategoryAndLimitedMembers", andMap); + +productCategory = catResult.productCategory; +productCategoryMembers = catResult.productCategoryMembers; + +// Prevents out of stock product to be displayed on site +productStore = ProductStoreWorker.getProductStore(request); +if (productStore) { + if ("N".equals(productStore.showOutOfStockProducts)) { + productsInStock = []; + productCategoryMembers.each { productCategoryMember -> + productFacility = delegator.findOne("ProductFacility", [productId : productCategoryMember.productId, facilityId : productStore.inventoryFacilityId], true); + if (productFacility) { + if (productFacility.lastInventoryCount >= 1) { + productsInStock.add(productCategoryMember); + } + } + } + context.productCategoryMembers = productsInStock; + } else { + context.productCategoryMembers = productCategoryMembers; + } +} +context.productCategory = productCategory; +context.viewIndex = catResult.viewIndex; +context.viewSize = catResult.viewSize; +context.lowIndex = catResult.lowIndex; +context.highIndex = catResult.highIndex; +context.listSize = catResult.listSize; + +// set this as a last viewed +// DEJ20070220: WHY is this done this way? why not use the existing CategoryWorker stuff? +LAST_VIEWED_TO_KEEP = 10; // modify this to change the number of last viewed to keep +lastViewedCategories = session.getAttribute("lastViewedCategories"); +if (!lastViewedCategories) { + lastViewedCategories = []; + session.setAttribute("lastViewedCategories", lastViewedCategories); +} +lastViewedCategories.remove(productCategoryId); +lastViewedCategories.add(0, productCategoryId); +while (lastViewedCategories.size() > LAST_VIEWED_TO_KEEP) { + lastViewedCategories.remove(lastViewedCategories.size() - 1); +} + +// set the content path prefix +contentPathPrefix = CatalogWorker.getContentPathPrefix(request); +context.put("contentPathPrefix", contentPathPrefix); + +// little routine to see if any members have a quantity > 0 assigned +members = context.get("productCategoryMembers"); +if (UtilValidate.isNotEmpty(members)) { + for (i = 0; i < members.size(); i++) { + productCategoryMember = (GenericValue) members.get(i); + if (productCategoryMember.get("quantity") != null && productCategoryMember.getDouble("quantity").doubleValue() > 0.0) { + context.put("hasQuantities", new Boolean(true)); + break; + } + } +} + +CategoryContentWrapper categoryContentWrapper = new CategoryContentWrapper(productCategory, request); +context.put("categoryContentWrapper", categoryContentWrapper); \ No newline at end of file Propchange: ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/catalog/CategoryDetail.groovy ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/catalog/CategoryDetail.groovy ------------------------------------------------------------------------------ svn:keywords = Date Rev Author URL Id Propchange: ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/catalog/CategoryDetail.groovy ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/catalog/SideDeepCategory.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/catalog/SideDeepCategory.groovy?rev=1125951&view=auto ============================================================================== --- ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/catalog/SideDeepCategory.groovy (added) +++ ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/catalog/SideDeepCategory.groovy Sun May 22 13:11:17 2011 @@ -0,0 +1,38 @@ +/* + * 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. + */ +import org.ofbiz.base.util.*; +import org.ofbiz.product.catalog.*; +import org.ofbiz.product.category.*; +import javolution.util.FastMap; + +CategoryWorker.getRelatedCategories(request, "topLevelList", CatalogWorker.getCatalogTopCategoryId(request, CatalogWorker.getCurrentCatalogId(request)), true); +curCategoryId = parameters.category_id ?: parameters.CATEGORY_ID ?: ""; +request.setAttribute("curCategoryId", curCategoryId); +CategoryWorker.setTrail(request, curCategoryId); + +categoryList = request.getAttribute("topLevelList"); +if (categoryList) { + catContentWrappers = FastMap.newInstance(); + CategoryWorker.getCategoryContentWrappers(catContentWrappers, categoryList, request); + context.catContentWrappers = catContentWrappers; +} +if (!curCategoryId && categoryList) { + curCategoryId = categoryList[0].productCategoryId; + request.setAttribute("topCategoryId", curCategoryId); +} \ No newline at end of file Propchange: ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/catalog/SideDeepCategory.groovy ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/catalog/SideDeepCategory.groovy ------------------------------------------------------------------------------ svn:keywords = Date Rev Author URL Id Propchange: ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/catalog/SideDeepCategory.groovy ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/customer/EditAddress.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/customer/EditAddress.groovy?rev=1125951&view=auto ============================================================================== --- ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/customer/EditAddress.groovy (added) +++ ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/customer/EditAddress.groovy Sun May 22 13:11:17 2011 @@ -0,0 +1,50 @@ +/* + * 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. + */ + +person = delegator.findOne("Person", [partyId : parameters.partyId], false); +if (person) { + request.setAttribute("lastName", person.lastName); + request.setAttribute("firstName", person.firstName); + request.setAttribute("partyId", parameters.partyId); +} + +contactMech = delegator.findOne("ContactMech", [contactMechId : parameters.contactMechId], false); +if (contactMech) { + postalAddress = contactMech.getRelatedOne("PostalAddress"); + if (postalAddress) { + request.setAttribute("contactMechId", postalAddress.contactMechId); + request.setAttribute("toName", postalAddress.toName); + request.setAttribute("attnName", postalAddress.attnName); + request.setAttribute("address1", postalAddress.address1); + request.setAttribute("address2", postalAddress.address2); + request.setAttribute("city", postalAddress.city); + request.setAttribute("postalCode", postalAddress.postalCode); + request.setAttribute("stateProvinceGeoId", postalAddress.stateProvinceGeoId); + request.setAttribute("countryGeoId", postalAddress.countryGeoId); + stateProvinceGeo = delegator.findOne("Geo", [geoId : postalAddress.stateProvinceGeoId], false); + if (stateProvinceGeo) { + request.setAttribute("stateProvinceGeo", stateProvinceGeo.get("geoName", locale)); + } + countryProvinceGeo = delegator.findOne("Geo", [geoId : postalAddress.countryGeoId], false); + if (countryProvinceGeo) { + request.setAttribute("countryProvinceGeo", countryProvinceGeo.get("geoName", locale)); + } + } +} +request.setAttribute("contactMechPurposeTypeId", parameters.contactMechPurposeTypeId); \ No newline at end of file Propchange: ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/customer/EditAddress.groovy ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/customer/EditAddress.groovy ------------------------------------------------------------------------------ svn:keywords = Date Rev Author URL Id Propchange: ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/customer/EditAddress.groovy ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/search/CustomerAddress.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/search/CustomerAddress.groovy?rev=1125951&view=auto ============================================================================== --- ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/search/CustomerAddress.groovy (added) +++ ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/search/CustomerAddress.groovy Sun May 22 13:11:17 2011 @@ -0,0 +1,47 @@ +/* + * 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. + */ +import org.ofbiz.base.util.UtilValidate; +import org.ofbiz.webpos.WebPosEvents; + +webPosSession = WebPosEvents.getWebPosSession(request, null); +if (webPosSession) { + shoppingCart = webPosSession.getCart(); + shipToCustomerPartyId = shoppingCart.getShipToCustomerPartyId(); + if (UtilValidate.isNotEmpty(shipToCustomerPartyId)) { + context.personShipTo = delegator.findOne("Person", [partyId : shipToCustomerPartyId], false); + } + shippingContactMechId = shoppingCart.getContactMech("SHIPPING_LOCATION"); + if (UtilValidate.isNotEmpty(shippingContactMechId)) { + contactMech = delegator.findOne("ContactMech", [contactMechId : shippingContactMechId], false); + if (UtilValidate.isNotEmpty(contactMech) && "POSTAL_ADDRESS".equals(contactMech.contactMechTypeId)) { + context.shippingPostalAddress = contactMech.getRelatedOne("PostalAddress"); + } + } + billToCustomerPartyId = shoppingCart.getBillToCustomerPartyId(); + if (UtilValidate.isNotEmpty(billToCustomerPartyId)) { + context.personBillTo = delegator.findOne("Person", [partyId : billToCustomerPartyId], false); + } + billingContactMechId = shoppingCart.getContactMech("BILLING_LOCATION"); + if (UtilValidate.isNotEmpty(billingContactMechId)) { + contactMech = delegator.findOne("ContactMech", [contactMechId : billingContactMechId], false); + if (UtilValidate.isNotEmpty(contactMech) && "POSTAL_ADDRESS".equals(contactMech.contactMechTypeId)) { + context.billingPostalAddress = contactMech.getRelatedOne("PostalAddress"); + } + } +} \ No newline at end of file Propchange: ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/search/CustomerAddress.groovy ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/search/CustomerAddress.groovy ------------------------------------------------------------------------------ svn:keywords = Date Rev Author URL Id Propchange: ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/search/CustomerAddress.groovy ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/search/SearchSalesReps.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/search/SearchSalesReps.groovy?rev=1125951&view=auto ============================================================================== --- ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/search/SearchSalesReps.groovy (added) +++ ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/search/SearchSalesReps.groovy Sun May 22 13:11:17 2011 @@ -0,0 +1,32 @@ +/* + * 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. + */ + +import org.ofbiz.entity.condition.EntityCondition; +import org.ofbiz.entity.condition.EntityOperator; + +List partyRoleCond = []; +List orderBy = ["lastName", "firstName"]; + +partyRoleCond.add(EntityCondition.makeCondition("roleTypeId", EntityOperator.EQUALS, "SALES_REP")); +context.salesReps = delegator.findList("PartyRoleNameDetail", EntityCondition.makeCondition(partyRoleCond, EntityOperator.AND), null, orderBy, null, false); + +shoppingCart = session.getAttribute("shoppingCart"); +if (shoppingCart) { + context.cartSalesReps = shoppingCart.getAdditionalPartyRoleMap().SALES_REP; +} \ No newline at end of file Propchange: ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/search/SearchSalesReps.groovy ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/search/SearchSalesReps.groovy ------------------------------------------------------------------------------ svn:keywords = Date Rev Author URL Id Propchange: ofbiz/trunk/specialpurpose/webpos/webapp/webpos/WEB-INF/actions/search/SearchSalesReps.groovy ------------------------------------------------------------------------------ svn:mime-type = text/plain |
Free forum by Nabble | Edit this page |