Author: jleroux
Date: Tue Oct 13 21:03:01 2009 New Revision: 824927 URL: http://svn.apache.org/viewvc?rev=824927&view=rev Log: Finally allows to create a POS customer with only a name (last name). Having the four fields (name, email, phone, card id) mandatory was too much constraints in most cases and not needed at all : we only need to create a Party after all. Modified: ofbiz/trunk/specialpurpose/pos/config/PosUiLabels.xml ofbiz/trunk/specialpurpose/pos/config/XuiLabels.properties ofbiz/trunk/specialpurpose/pos/config/XuiLabels_fr.properties ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/PosTransaction.java ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/screen/ClientProfile.java Modified: ofbiz/trunk/specialpurpose/pos/config/PosUiLabels.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/pos/config/PosUiLabels.xml?rev=824927&r1=824926&r2=824927&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/pos/config/PosUiLabels.xml (original) +++ ofbiz/trunk/specialpurpose/pos/config/PosUiLabels.xml Tue Oct 13 21:03:01 2009 @@ -27,9 +27,9 @@ <value xml:lang="ro">(adjustment)</value> <value xml:lang="zh">(è°æ´)</value> </property> - <property key="PosAllFieldsAreRequired"> - <value xml:lang="en">All fields are required</value> - <value xml:lang="fr">Tous les champs doivent être renseignés</value> + <property key="PosNameFieldRequired"> + <value xml:lang="en">The name is required</value> + <value xml:lang="fr">Le nom doit être renseigné</value> </property> <property key="PosAmt"> <value xml:lang="en">AMT</value> Modified: ofbiz/trunk/specialpurpose/pos/config/XuiLabels.properties URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/pos/config/XuiLabels.properties?rev=824927&r1=824926&r2=824927&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/pos/config/XuiLabels.properties (original) +++ ofbiz/trunk/specialpurpose/pos/config/XuiLabels.properties Tue Oct 13 21:03:01 2009 @@ -105,4 +105,4 @@ problems_reading_card=PROBLEMS READING SWIPED CARD product_not_found=PRODUCT NOT FOUND reasonCommentInOut=Comment -tipLoginPwd=* Initial email address and card number are also used respectively as login and password +tipLoginPwd=* Email address and card number are also used respectively as login and password Modified: ofbiz/trunk/specialpurpose/pos/config/XuiLabels_fr.properties URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/pos/config/XuiLabels_fr.properties?rev=824927&r1=824926&r2=824927&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/pos/config/XuiLabels_fr.properties (original) +++ ofbiz/trunk/specialpurpose/pos/config/XuiLabels_fr.properties Tue Oct 13 21:03:01 2009 @@ -106,4 +106,4 @@ product_not_found=Produit inconnu ! promo_page=Ce sera la page des promotions... reasonCommentInOut=Commentaire -tipLoginPwd=* L'adresse courriel et le n\u00b0 de carte intials sont aussi utilis\u00e9s respectiv. comme id. de connexion et mot de passe +tipLoginPwd=* L'adresse courriel et le n\u00b0 de carte sont aussi utilis\u00e9s respectiv. comme id. de connexion et mot de passe 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=824927&r1=824926&r2=824927&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/PosTransaction.java (original) +++ ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/PosTransaction.java Tue Oct 13 21:03:01 2009 @@ -49,6 +49,7 @@ 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; @@ -1539,9 +1540,6 @@ public List<Map<String, String>> searchClientProfile(String name, String email, String phone, String card, PosScreen pos) { Delegator delegator = this.session.getDelegator(); - LocalDispatcher dispatcher = session.getDispatcher(); - GenericValue userLogin = session.getUserLogin(); - Locale locale = defaultLocale; List<GenericValue> partyList = null; List<Map<String, String>> resultList = null; @@ -1554,18 +1552,14 @@ dynamicView.addAlias("PT", "partyId"); dynamicView.addAlias("PT", "statusId"); dynamicView.addAlias("PT", "partyTypeId"); - dynamicView.addMemberEntity("PUL", "PartyAndUserLogin"); - dynamicView.addAlias("PUL", "userLoginId"); dynamicView.addMemberEntity("PE", "Person"); dynamicView.addAlias("PE", "partyId"); dynamicView.addAlias("PE", "lastName"); dynamicView.addAlias("PE", "memberId"); - dynamicView.addAlias("PE", "lastNameLocal"); dynamicView.addViewLink("PT", "PE", Boolean.FALSE, ModelKeyMap.makeKeyMapList("partyId")); - dynamicView.addViewLink("PT", "PUL", Boolean.FALSE, ModelKeyMap.makeKeyMapList("partyId")); Boolean onlyPhone = UtilValidate.isEmpty(name) && UtilValidate.isEmpty(email) && UtilValidate.isNotEmpty(phone) && UtilValidate.isEmpty(card); - if (!onlyPhone) { + if (UtilValidate.isNotEmpty(email)) { // ContactMech (email) dynamicView.addMemberEntity("PM", "PartyContactMechPurpose"); dynamicView.addAlias("PM", "contactMechId"); @@ -1575,7 +1569,7 @@ dynamicView.addAlias("CM", "infoString"); dynamicView.addViewLink("PT", "PM", Boolean.FALSE, ModelKeyMap.makeKeyMapList("partyId")); dynamicView.addViewLink("PM", "CM", Boolean.FALSE, ModelKeyMap.makeKeyMapList("contactMechId")); - } else { + } else if (onlyPhone) { dynamicView.addMemberEntity("PM", "PartyContactMechPurpose"); dynamicView.addAlias("PM", "contactMechId"); dynamicView.addAlias("PM", "thruDate"); @@ -1596,9 +1590,9 @@ fieldsToSelect.add("partyId"); fieldsToSelect.add("lastName"); fieldsToSelect.add("memberId"); - if (!onlyPhone) { + if (UtilValidate.isNotEmpty(email)) { fieldsToSelect.add("infoString"); - } else { + } else if (onlyPhone) { fieldsToSelect.add("contactNumber"); } @@ -1606,9 +1600,11 @@ // This allows to get all clients when any informations has been entered andExprs.add(EntityCondition.makeCondition(EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, null), EntityOperator.OR, EntityCondition.makeCondition("statusId", EntityOperator.NOT_EQUAL, "PARTY_DISABLED"))); andExprs.add(EntityCondition.makeCondition("partyTypeId", EntityOperator.EQUALS, "PERSON")); // Only persons for now... - andExprs.add(EntityCondition.makeCondition("userLoginId", EntityOperator.NOT_EQUAL, null)); // Should have a login if (UtilValidate.isNotEmpty(name)) { - andExprs.add(EntityCondition.makeCondition("lastName", EntityOperator.EQUALS, name)); + // andExprs.add(EntityCondition.makeCondition("lastName", EntityOperator.EQUALS, name)); // Plain name + // andExprs.add(EntityCondition.makeCondition("lastName", EntityOperator.LIKE, "%"+name+"%")); // Less restrictive + andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER_FIELD("lastName"), EntityOperator.LIKE, EntityFunction.UPPER("%"+name+"%"))); // Even less restrictive + } if (UtilValidate.isNotEmpty(card)) { andExprs.add(EntityCondition.makeCondition("memberId", EntityOperator.EQUALS, card)); @@ -1622,12 +1618,8 @@ andExprs.add(EntityCondition.makeCondition("contactNumber", EntityOperator.EQUALS, phone)); andExprs.add(EntityCondition.makeCondition("contactMechPurposeTypeId", EntityOperator.EQUALS, "PHONE_HOME")); andExprs.add(EntityCondition.makeCondition("thruDate", EntityOperator.EQUALS, null)); - } else if (UtilValidate.isEmpty(email)) { - andExprs.add(EntityCondition.makeCondition("infoString", EntityOperator.NOT_EQUAL, null)); - andExprs.add(EntityCondition.makeCondition("contactMechPurposeTypeId", EntityOperator.EQUALS, "PRIMARY_EMAIL")); - andExprs.add(EntityCondition.makeCondition("thruDate", EntityOperator.EQUALS, null)); } - + mainCond = EntityCondition.makeCondition(andExprs, EntityOperator.AND); orderBy.add("lastName"); @@ -1679,19 +1671,27 @@ partyMap.put("partyId", party.getString("partyId")); partyMap.put("lastName", party.getString("lastName")); partyMap.put("memberId", party.getString("memberId")); - if (!onlyPhone) { + if (!onlyPhone && UtilValidate.isNotEmpty(email)) { partyMap.put("infoString", party.getString("infoString")); partyMap.put("contactNumber", ""); + } else if (UtilValidate.isEmpty(email) && !onlyPhone) { + partyMap.put("infoString", ""); + partyMap.put("contactNumber", ""); } else { partyMap.put("contactNumber", party.getString("contactNumber")); partyMap.put("infoString", ""); + } resultList.add(partyMap); } - if (!onlyPhone) { + + if (!onlyPhone && UtilValidate.isNotEmpty(email)) { resultList = searchContactMechs(delegator, pos, resultList, phone, "TELECOM_NUMBER"); - } else { - resultList = searchContactMechs(delegator, pos, resultList, "", "EMAIL_ADDRESS"); //"" is more clear than email which is by definition here is empty + } else if (UtilValidate.isEmpty(email) && !onlyPhone){ + resultList = searchContactMechs(delegator, pos, resultList, "", "TELECOM_NUMBER"); // "" is more clear than phone which is by definition here is empty + resultList = searchContactMechs(delegator, pos, resultList, "", "EMAIL_ADDRESS"); // "" is more clear than email which is by definition here is empty + } else { // onlyPhone + resultList = searchContactMechs(delegator, pos, resultList, "", "EMAIL_ADDRESS"); } } else { resultList = FastList.newInstance(); @@ -1712,67 +1712,94 @@ Map<String, Object> svcCtx = FastMap.newInstance(); Map svcRes = null; + // Create if ("create".equals(editType)) { - // Create trace("Create a client profile"); - svcCtx.put("memberId", card); - svcCtx.put("lastName", name); - svcCtx.put("firstName", ""); // Needed by service createPersonAndUserLogin - svcCtx.put("userLogin", userLogin); - svcCtx.put("userLoginId", email); - svcCtx.put("currentPassword", card); - svcCtx.put("currentPasswordVerify", card); - svcCtx.put("passwordHint", "Your card number is your password"); - - // createPersonAndUserLogin - try { - svcRes = dispatcher.runSync("createPersonAndUserLogin", svcCtx); - } catch (GenericServiceException e) { - Debug.logError(e, module); - pos.showDialog("dialog/error/exception", e.getMessage()); - return result; - } - if (ServiceUtil.isError(svcRes)) { - pos.showDialog("dialog/error/exception", ServiceUtil.getErrorMessage(svcRes)); - return result; + if (UtilValidate.isNotEmpty(name)) { + // createPersonAndUserLogin + trace("createPersonAndUserLogin"); + if (UtilValidate.isNotEmpty(card)) { + svcCtx.put("memberId", card); + } + svcCtx.put("lastName", name); + svcCtx.put("firstName", ""); // Needed by service createPersonAndUserLogin + svcCtx.put("userLogin", userLogin); + if (UtilValidate.isNotEmpty(email) && UtilValidate.isNotEmpty(card)) { + svcCtx.put("userLoginId", email); + svcCtx.put("currentPassword", card); + svcCtx.put("currentPasswordVerify", card); + svcCtx.put("passwordHint", "Your card number is your password"); + try { + svcRes = dispatcher.runSync("createPersonAndUserLogin", svcCtx); + } catch (GenericServiceException e) { + Debug.logError(e, module); + pos.showDialog("dialog/error/exception", e.getMessage()); + return result; + } + if (ServiceUtil.isError(svcRes)) { + pos.showDialog("dialog/error/exception", ServiceUtil.getErrorMessage(svcRes)); + return result; + } + + } else { + // createPerson + trace("createPerson"); + try { + svcRes = dispatcher.runSync("createPerson", svcCtx); + } catch (GenericServiceException e) { + Debug.logError(e, module); + pos.showDialog("dialog/error/exception", e.getMessage()); + return result; + } + if (ServiceUtil.isError(svcRes)) { + pos.showDialog("dialog/error/exception", ServiceUtil.getErrorMessage(svcRes)); + return result; + } + } + + partyId = (String) svcRes.get("partyId"); } - partyId = (String) svcRes.get("partyId"); - GenericValue newUserLogin = (GenericValue) svcRes.get("newUserLogin"); - // createPartyEmailAddress - svcCtx.clear(); - svcCtx.put("userLogin", newUserLogin); - svcCtx.put("emailAddress", email); - svcCtx.put("partyId", partyId); - svcCtx.put("contactMechPurposeTypeId", "PRIMARY_EMAIL"); - try { - svcRes = dispatcher.runSync("createPartyEmailAddress", svcCtx); - } catch (GenericServiceException e) { - Debug.logError(e, module); - pos.showDialog("dialog/error/exception", e.getMessage()); - return result; - } - if (ServiceUtil.isError(svcRes)) { - pos.showDialog("dialog/error/exception", ServiceUtil.getErrorMessage(svcRes)); - return result; + if (UtilValidate.isNotEmpty(email)) { + // createPartyEmailAddress + trace("createPartyEmailAddress"); + svcCtx.clear(); + svcCtx.put("userLogin", userLogin); + svcCtx.put("emailAddress", email); + svcCtx.put("partyId", partyId); + svcCtx.put("contactMechPurposeTypeId", "PRIMARY_EMAIL"); + try { + svcRes = dispatcher.runSync("createPartyEmailAddress", svcCtx); + } catch (GenericServiceException e) { + Debug.logError(e, module); + pos.showDialog("dialog/error/exception", e.getMessage()); + return result; + } + if (ServiceUtil.isError(svcRes)) { + pos.showDialog("dialog/error/exception", ServiceUtil.getErrorMessage(svcRes)); + return result; + } } - // createPartyTelecomNumber - svcCtx.clear(); - svcCtx.put("userLogin", newUserLogin); - svcCtx.put("contactNumber", phone); - svcCtx.put("partyId", partyId); - svcCtx.put("contactMechPurposeTypeId", "PHONE_HOME"); - try { - svcRes = dispatcher.runSync("createPartyTelecomNumber", svcCtx); - } catch (GenericServiceException e) { - Debug.logError(e, module); - pos.showDialog("dialog/error/exception", e.getMessage()); - return result; - } - if (ServiceUtil.isError(svcRes)) { - pos.showDialog("dialog/error/exception", ServiceUtil.getErrorMessage(svcRes)); - return result; + if (UtilValidate.isNotEmpty(phone)) { + // createPartyTelecomNumber + trace("createPartyTelecomNumber"); + svcCtx.clear(); + svcCtx.put("userLogin", userLogin); + svcCtx.put("contactNumber", phone); + svcCtx.put("partyId", partyId); + svcCtx.put("contactMechPurposeTypeId", "PHONE_HOME"); + try { + svcRes = dispatcher.runSync("createPartyTelecomNumber", svcCtx); + } catch (GenericServiceException e) { + Debug.logError(e, module); + pos.showDialog("dialog/error/exception", e.getMessage()); + return result; + } + if (ServiceUtil.isError(svcRes)) { + pos.showDialog("dialog/error/exception", ServiceUtil.getErrorMessage(svcRes)); + return result; + } } result = partyId; } else { @@ -1860,6 +1887,7 @@ pos.showDialog("dialog/error/exception", ServiceUtil.getErrorMessage(svcRes)); return result; } + partyLogin = (GenericValue) svcRes.get("newUserLogin"); svcCtx.clear(); Modified: ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/screen/ClientProfile.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/screen/ClientProfile.java?rev=824927&r1=824926&r2=824927&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/screen/ClientProfile.java (original) +++ ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/screen/ClientProfile.java Tue Oct 13 21:03:01 2009 @@ -233,14 +233,10 @@ String email = m_emailEdit.getText().trim(); String phone = m_phoneEdit.getText().trim(); String card = m_cardEdit.getText().trim(); - if (UtilValidate.isNotEmpty(name) - && UtilValidate.isNotEmpty(email) - && UtilValidate.isNotEmpty(phone) - && UtilValidate.isNotEmpty(card) - ) { + if (UtilValidate.isNotEmpty(name)) { editClientProfile(name, email, phone, card, editType, m_partyId); } else { - m_pos.showDialog("dialog/error/exception", UtilProperties.getMessage(PosTransaction.resource, "PosAllFieldsAreRequired", locale)); + m_pos.showDialog("dialog/error/exception", UtilProperties.getMessage(PosTransaction.resource, "PosNameFieldRequired", locale)); } } } |
Free forum by Nabble | Edit this page |