Refactoring of Create Client/U_WebMenu in Posterita
This commit is contained in:
parent
adfa9e6453
commit
f6c57ad49a
|
@ -30,10 +30,12 @@ import javax.servlet.http.HttpServletResponse;
|
||||||
import org.apache.struts.action.ActionForm;
|
import org.apache.struts.action.ActionForm;
|
||||||
import org.apache.struts.action.ActionForward;
|
import org.apache.struts.action.ActionForward;
|
||||||
import org.apache.struts.action.ActionMapping;
|
import org.apache.struts.action.ActionMapping;
|
||||||
|
import org.compiere.model.MStore;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
import org.posterita.Constants;
|
import org.posterita.Constants;
|
||||||
import org.posterita.beans.ApplicationParametersBean;
|
import org.posterita.beans.ApplicationParametersBean;
|
||||||
import org.posterita.businesslogic.ApplicationManager;
|
import org.posterita.businesslogic.ApplicationManager;
|
||||||
|
import org.posterita.businesslogic.StoreManager;
|
||||||
import org.posterita.core.TmkJSPEnv;
|
import org.posterita.core.TmkJSPEnv;
|
||||||
import org.posterita.exceptions.DefaultStoreException;
|
import org.posterita.exceptions.DefaultStoreException;
|
||||||
import org.posterita.lib.UdiConstants;
|
import org.posterita.lib.UdiConstants;
|
||||||
|
@ -51,10 +53,11 @@ public class GoToHomePageAction extends BaseDispatchAction
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ApplicationManager.changeApplication(request, response);
|
Properties ctx = Env.getCtx();
|
||||||
|
MStore store = StoreManager.getDefaultStore(ctx);
|
||||||
Properties ctx = TmkJSPEnv.getCtx(request);
|
ApplicationManager.setApplicationParametersInContext(ctx, store.get_ID());
|
||||||
String forward = Env.getContext(ctx, UdiConstants.WEBPARAM6);
|
ctx = TmkJSPEnv.getCtx(request);
|
||||||
|
String forward = Env.getContext(ctx, UdiConstants.DEFAULT_FORWARD);
|
||||||
|
|
||||||
return mapping.findForward(forward);
|
return mapping.findForward(forward);
|
||||||
}
|
}
|
||||||
|
@ -65,39 +68,38 @@ public class GoToHomePageAction extends BaseDispatchAction
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final String LICENSE_INVALID = "clientLicensing";
|
|
||||||
public static final String CHOOSE_APPLICATION = "chooseApplication";
|
public static final String CHOOSE_APPLICATION = "chooseApplication";
|
||||||
public ActionForward setApplicationParameters(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception
|
public ActionForward setApplicationParameters(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception
|
||||||
{
|
{
|
||||||
DefaultForm df = (DefaultForm) form;
|
DefaultForm df = (DefaultForm) form;
|
||||||
ApplicationParametersBean bean = (ApplicationParametersBean) df.getBean();
|
ApplicationParametersBean bean = (ApplicationParametersBean) df.getBean();
|
||||||
|
|
||||||
String appName = bean.getApplicationName();
|
Integer storeId = bean.getStoreId();
|
||||||
|
|
||||||
try
|
// Store not defined, should go to default store or choose from different stores
|
||||||
|
if (storeId == null)
|
||||||
{
|
{
|
||||||
ApplicationManager.changeApplication(request, response, appName);
|
return goToHomePage(mapping, form, request, response);
|
||||||
|
|
||||||
Properties ctx = TmkJSPEnv.getCtx(request);
|
|
||||||
String defaultAppName = ApplicationManager.getApplicationType(ctx).toUpperCase();
|
|
||||||
|
|
||||||
String displayAppName = ApplicationManager.getApplicationName(bean.getApplicationName());
|
|
||||||
|
|
||||||
request.getSession().getServletContext().setAttribute(Constants.APP_NAME,displayAppName);
|
|
||||||
|
|
||||||
ApplicationManager.setApplicationNameInCookie(response, appName);
|
|
||||||
|
|
||||||
String forward = Env.getContext(ctx, UdiConstants.WEBPARAM6);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return mapping.findForward(forward);
|
|
||||||
}
|
}
|
||||||
catch(DefaultStoreException ex)
|
|
||||||
|
Properties ctx = Env.getCtx();
|
||||||
|
|
||||||
|
MStore store = new MStore(ctx, storeId, null);
|
||||||
|
|
||||||
|
if (store.get_ID() == 0)
|
||||||
{
|
{
|
||||||
postGlobalError("error.store.default", ex.getMessage(), request);
|
//TODO: Add error message showing no store error to user
|
||||||
return mapping.findForward(CHOOSE_APPLICATION);
|
mapping.findForward(CHOOSE_APPLICATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ApplicationManager.setApplicationParametersInContext(ctx, storeId);
|
||||||
|
|
||||||
|
ctx = TmkJSPEnv.getCtx(request);
|
||||||
|
|
||||||
|
request.getSession().getServletContext().setAttribute(Constants.APP_NAME, bean.getApplicationName());
|
||||||
|
|
||||||
|
return mapping.findForward(UdiConstants.DEFAULT_FORWARD);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final String INIT_CHOOSE_APPLICATION = "initChooseApplication";
|
public static final String INIT_CHOOSE_APPLICATION = "initChooseApplication";
|
||||||
|
|
|
@ -35,7 +35,7 @@ import org.apache.struts.action.ActionMapping;
|
||||||
import org.apache.struts.util.MessageResources;
|
import org.apache.struts.util.MessageResources;
|
||||||
import org.compiere.model.MSession;
|
import org.compiere.model.MSession;
|
||||||
import org.compiere.model.MUser;
|
import org.compiere.model.MUser;
|
||||||
import org.compiere.model.X_U_Menu;
|
import org.compiere.model.X_U_WebMenu;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
import org.compiere.util.KeyNamePair;
|
import org.compiere.util.KeyNamePair;
|
||||||
import org.compiere.util.WebUser;
|
import org.compiere.util.WebUser;
|
||||||
|
@ -60,7 +60,7 @@ import org.posterita.exceptions.UserInactiveException;
|
||||||
import org.posterita.exceptions.UserNotFoundException;
|
import org.posterita.exceptions.UserNotFoundException;
|
||||||
import org.posterita.exceptions.WrongPasswordException;
|
import org.posterita.exceptions.WrongPasswordException;
|
||||||
import org.posterita.lib.UdiConstants;
|
import org.posterita.lib.UdiConstants;
|
||||||
import org.posterita.model.UDIU_Menu;
|
import org.posterita.model.U_WebMenu;
|
||||||
import org.posterita.struts.core.BaseDispatchAction;
|
import org.posterita.struts.core.BaseDispatchAction;
|
||||||
import org.posterita.struts.core.DefaultForm;
|
import org.posterita.struts.core.DefaultForm;
|
||||||
import org.posterita.user.WebUserInfo;
|
import org.posterita.user.WebUserInfo;
|
||||||
|
@ -104,11 +104,11 @@ public class LoginAction extends BaseDispatchAction
|
||||||
|
|
||||||
if(userId != null)
|
if(userId != null)
|
||||||
{
|
{
|
||||||
X_U_Menu xmenu = new X_U_Menu(ctx,0,null);
|
X_U_WebMenu xmenu = new X_U_WebMenu(ctx,0,null);
|
||||||
xmenu.setName("Switch User");
|
xmenu.setName("Switch User");
|
||||||
xmenu.setMenuLink("LoginUserAction.do?action=loginUser&userId=" + userId);
|
xmenu.setMenuLink("LoginUserAction.do?action=loginUser&userId=" + userId);
|
||||||
|
|
||||||
UDIU_Menu menu = new UDIU_Menu(xmenu);
|
U_WebMenu menu = new U_WebMenu(xmenu);
|
||||||
//MenuItem menuItem = new MenuItem(menu);
|
//MenuItem menuItem = new MenuItem(menu);
|
||||||
leftMenusList.add(new MenuItem(menu));
|
leftMenusList.add(new MenuItem(menu));
|
||||||
}
|
}
|
||||||
|
@ -165,7 +165,8 @@ public class LoginAction extends BaseDispatchAction
|
||||||
|
|
||||||
WebUserInfo wuInfo = (WebUserInfo)session.getAttribute(WebUserInfo.NAME);
|
WebUserInfo wuInfo = (WebUserInfo)session.getAttribute(WebUserInfo.NAME);
|
||||||
|
|
||||||
String appName = ApplicationManager.getApplicationType(ctx);
|
int storeId = Env.getContextAsInt(TmkJSPEnv.getCtx(request), UdiConstants.WSTORE_CTX_PARAM);
|
||||||
|
|
||||||
if (wuInfo != null)
|
if (wuInfo != null)
|
||||||
{
|
{
|
||||||
WebUser wu = wuInfo.getUser();
|
WebUser wu = wuInfo.getUser();
|
||||||
|
@ -173,21 +174,16 @@ public class LoginAction extends BaseDispatchAction
|
||||||
wu.logout();
|
wu.logout();
|
||||||
|
|
||||||
session.removeAttribute(WebUserInfo.NAME);
|
session.removeAttribute(WebUserInfo.NAME);
|
||||||
|
session.setMaxInactiveInterval(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(appName.endsWith(Constants.APP_POS))
|
|
||||||
session.setMaxInactiveInterval(0);
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ApplicationManager.changeApplication(request, response);
|
ctx = Env.getCtx();
|
||||||
|
ApplicationManager.setApplicationParametersInContext(ctx, storeId);
|
||||||
ctx = TmkJSPEnv.getCtx(request);
|
ctx = TmkJSPEnv.getCtx(request);
|
||||||
|
|
||||||
String forward = Env.getContext(ctx, UdiConstants.WEBPARAM6);
|
return mapping.findForward(UdiConstants.DEFAULT_FORWARD);
|
||||||
|
|
||||||
return mapping.findForward(forward);
|
|
||||||
}
|
}
|
||||||
catch(Exception ex)
|
catch(Exception ex)
|
||||||
{
|
{
|
||||||
|
@ -250,48 +246,36 @@ public class LoginAction extends BaseDispatchAction
|
||||||
return (mapping.getInputForward());
|
return (mapping.getInputForward());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String strPosId = POSManager.getPOSIDFromCookie(request);
|
||||||
|
boolean isValidPOSId = false;
|
||||||
|
|
||||||
|
if(strPosId != null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
int posId = Integer.parseInt(strPosId);
|
||||||
|
isValidPOSId = POSManager.isPOSTerminalPresent(ctx, posId);
|
||||||
|
}
|
||||||
|
catch(Exception ex)
|
||||||
|
{}
|
||||||
|
}
|
||||||
|
|
||||||
String applicationName = ApplicationManager.getApplicationType(ctx);
|
if(!isValidPOSId)
|
||||||
|
{
|
||||||
if(applicationName.endsWith(Constants.APP_POS))
|
ArrayList list=POSManager.getAllPOSIDs(ctx);
|
||||||
{
|
request.getSession().setAttribute(Constants.POSIDS,list);
|
||||||
String strPosId = POSManager.getPOSIDFromCookie(request);
|
return mapping.findForward(CHOOSEPOS);
|
||||||
|
|
||||||
|
}
|
||||||
boolean isValidPOSId = false;
|
else
|
||||||
|
{
|
||||||
if(strPosId != null)
|
SessionStorage.putPOSID(ctx,strPosId,request);
|
||||||
{
|
String currSymboleSales = POSTerminalManager.getPOSDefaultSellCurrency(ctx).getCurSymbol();
|
||||||
try
|
String currSymbolePurchase=POSTerminalManager.getPOSDefaultPurchaseCurrency(ctx).getCurSymbol();
|
||||||
{
|
request.getSession().setAttribute(Constants.CURRENCY_SYMBOLE,currSymboleSales);
|
||||||
int posId = Integer.parseInt(strPosId);
|
request.getSession().setAttribute(Constants.CURRENCY_SYMBOLE_PURCHASE,currSymbolePurchase);
|
||||||
isValidPOSId = POSManager.isPOSTerminalPresent(ctx, posId);
|
return mapping.findForward(CREATEPOSORDER);
|
||||||
}
|
}
|
||||||
catch(Exception ex)
|
|
||||||
{}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if(!isValidPOSId)
|
|
||||||
{
|
|
||||||
ArrayList list=POSManager.getAllPOSIDs(ctx);
|
|
||||||
request.getSession().setAttribute(Constants.POSIDS,list);
|
|
||||||
return mapping.findForward(CHOOSEPOS);
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SessionStorage.putPOSID(ctx,strPosId,request);
|
|
||||||
String currSymboleSales = POSTerminalManager.getPOSDefaultSellCurrency(ctx).getCurSymbol();
|
|
||||||
String currSymbolePurchase=POSTerminalManager.getPOSDefaultPurchaseCurrency(ctx).getCurSymbol();
|
|
||||||
request.getSession().setAttribute(Constants.CURRENCY_SYMBOLE,currSymboleSales);
|
|
||||||
request.getSession().setAttribute(Constants.CURRENCY_SYMBOLE_PURCHASE,currSymbolePurchase);
|
|
||||||
return mapping.findForward(CREATEPOSORDER);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return mapping.findForward(SUCCESS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ActionForward password(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception
|
public ActionForward password(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception
|
||||||
|
|
|
@ -128,50 +128,37 @@ public class POSLoginAction extends BaseDispatchAction
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
String applicationName = ApplicationManager.getApplicationType(ctx);
|
|
||||||
|
|
||||||
if(applicationName.endsWith(Constants.APP_POS))
|
String strPosId = POSManager.getPOSIDFromCookie(request);
|
||||||
|
boolean isValidPOSId = false;
|
||||||
|
|
||||||
|
if(strPosId != null)
|
||||||
{
|
{
|
||||||
String strPosId = POSManager.getPOSIDFromCookie(request);
|
try
|
||||||
|
|
||||||
|
|
||||||
boolean isValidPOSId = false;
|
|
||||||
|
|
||||||
if(strPosId != null)
|
|
||||||
{
|
{
|
||||||
try
|
int posId = Integer.parseInt(strPosId);
|
||||||
{
|
isValidPOSId = POSManager.isPOSTerminalPresent(ctx, posId);
|
||||||
int posId = Integer.parseInt(strPosId);
|
|
||||||
isValidPOSId = POSManager.isPOSTerminalPresent(ctx, posId);
|
|
||||||
}
|
|
||||||
catch(Exception ex)
|
|
||||||
{}
|
|
||||||
}
|
}
|
||||||
|
catch(Exception ex)
|
||||||
|
{}
|
||||||
if(!isValidPOSId)
|
|
||||||
{
|
|
||||||
ArrayList list=POSManager.getAllPOSIDs(ctx);
|
|
||||||
request.getSession().setAttribute(Constants.POSIDS,list);
|
|
||||||
return mapping.findForward(CHOOSEPOS);
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SessionStorage.putPOSID(ctx,strPosId,request);
|
|
||||||
String currSymboleSales = POSTerminalManager.getPOSDefaultSellCurrency(ctx).getCurSymbol();
|
|
||||||
String currSymbolePurchase=POSTerminalManager.getPOSDefaultPurchaseCurrency(ctx).getCurSymbol();
|
|
||||||
request.getSession().setAttribute(Constants.CURRENCY_SYMBOLE,currSymboleSales);
|
|
||||||
request.getSession().setAttribute(Constants.CURRENCY_SYMBOLE_PURCHASE,currSymbolePurchase);
|
|
||||||
return mapping.findForward(CREATEPOSORDER);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SessionStorage.putOrg(ctx, request);
|
if(!isValidPOSId)
|
||||||
SessionStorage.putWebstoreUser(ctx, request, info.getUser().getAD_User_ID());
|
{
|
||||||
|
ArrayList list=POSManager.getAllPOSIDs(ctx);
|
||||||
return mapping.findForward(SUCCESS);
|
request.getSession().setAttribute(Constants.POSIDS,list);
|
||||||
|
return mapping.findForward(CHOOSEPOS);
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SessionStorage.putPOSID(ctx,strPosId,request);
|
||||||
|
String currSymboleSales = POSTerminalManager.getPOSDefaultSellCurrency(ctx).getCurSymbol();
|
||||||
|
String currSymbolePurchase=POSTerminalManager.getPOSDefaultPurchaseCurrency(ctx).getCurSymbol();
|
||||||
|
request.getSession().setAttribute(Constants.CURRENCY_SYMBOLE,currSymboleSales);
|
||||||
|
request.getSession().setAttribute(Constants.CURRENCY_SYMBOLE_PURCHASE,currSymbolePurchase);
|
||||||
|
return mapping.findForward(CREATEPOSORDER);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -75,29 +75,11 @@ public class MenuAction extends BaseDispatchAction
|
||||||
|
|
||||||
if(rootMenuItem == null)
|
if(rootMenuItem == null)
|
||||||
{
|
{
|
||||||
try
|
//TODO: Display error message or should kick to right store
|
||||||
{
|
mapping.findForward(CHOOSE_APPLICATION);
|
||||||
ApplicationManager.changeApplication(request, response);
|
|
||||||
|
|
||||||
ctx = TmkJSPEnv.getCtx(request);
|
|
||||||
String forward = Env.getContext(ctx, UdiConstants.WEBPARAM6);
|
|
||||||
|
|
||||||
return mapping.findForward(forward);
|
|
||||||
}
|
|
||||||
catch(DefaultStoreException ex)
|
|
||||||
{
|
|
||||||
postGlobalError("error.store.default", ex.getMessage(), request);
|
|
||||||
return mapping.findForward(CHOOSE_APPLICATION);
|
|
||||||
}
|
|
||||||
catch(Exception ex)
|
|
||||||
{
|
|
||||||
return mapping.findForward(APPLICATION_ERROR);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayList subMenus = new ArrayList();
|
ArrayList subMenus = new ArrayList();
|
||||||
String applicationName = ApplicationManager.getApplicationType(ctx).toUpperCase();
|
|
||||||
|
|
||||||
if(bean.getMenuId()==null)
|
if(bean.getMenuId()==null)
|
||||||
{
|
{
|
||||||
UDIPO udiPO = POSMenuFactory.getFactoryInstance(ctx).get(ctx, POSMenuFactory.PMENU_SALES_ID);
|
UDIPO udiPO = POSMenuFactory.getFactoryInstance(ctx).get(ctx, POSMenuFactory.PMENU_SALES_ID);
|
||||||
|
@ -109,67 +91,109 @@ public class MenuAction extends BaseDispatchAction
|
||||||
subMenus = rootMenuItem.getSubMenus(bean.getMenuId().intValue());
|
subMenus = rootMenuItem.getSubMenus(bean.getMenuId().intValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//subgrouping menus
|
||||||
|
ArrayList<MenuItem> menuItems = subMenus;
|
||||||
|
HashMap<String,ArrayList<MenuItem>> categoryMap = new HashMap<String,ArrayList<MenuItem>>();
|
||||||
|
|
||||||
|
StringWriter sw = new StringWriter();
|
||||||
if (applicationName.equalsIgnoreCase("POS"))
|
PrintWriter out = new PrintWriter(sw);
|
||||||
{
|
ElementBean elementBean = null;
|
||||||
//subgrouping menus
|
|
||||||
ArrayList<MenuItem> menuItems = subMenus;
|
String category = "";
|
||||||
HashMap<String,ArrayList<MenuItem>> categoryMap = new HashMap<String,ArrayList<MenuItem>>();
|
ArrayList<MenuItem> list = null;
|
||||||
|
ArrayList<String> categories = new ArrayList<String>();
|
||||||
StringWriter sw = new StringWriter();
|
|
||||||
PrintWriter out = new PrintWriter(sw);
|
//group menus
|
||||||
ElementBean elementBean = null;
|
for(MenuItem menuItem : menuItems)
|
||||||
|
{
|
||||||
|
category = menuItem.getCategory();
|
||||||
|
category = (category==null)? "" : category;
|
||||||
|
|
||||||
String category = "";
|
if(!categories.contains(category))
|
||||||
ArrayList<MenuItem> list = null;
|
{
|
||||||
ArrayList<String> categories = new ArrayList<String>();
|
categories.add(category);
|
||||||
|
}
|
||||||
//group menus
|
|
||||||
for(MenuItem menuItem : menuItems)
|
list = categoryMap.get(category);
|
||||||
{
|
|
||||||
category = menuItem.getCategory();
|
if(list==null)
|
||||||
category = (category==null)? "" : category;
|
{
|
||||||
|
list = new ArrayList<MenuItem>();
|
||||||
if(!categories.contains(category))
|
}
|
||||||
{
|
|
||||||
categories.add(category);
|
list.add(menuItem);
|
||||||
}
|
categoryMap.put(category,list);
|
||||||
|
|
||||||
list = categoryMap.get(category);
|
}
|
||||||
|
|
||||||
if(list==null)
|
//display groups
|
||||||
{
|
|
||||||
list = new ArrayList<MenuItem>();
|
Iterator<String> iter = categories.iterator();
|
||||||
}
|
|
||||||
|
out.print("<table class=\"main\" cellspacing=\"10\">");
|
||||||
list.add(menuItem);
|
while(iter.hasNext())
|
||||||
categoryMap.put(category,list);
|
{
|
||||||
|
out.print("<tr><td valign=\"top\" width=\"50%\">");
|
||||||
}
|
//----------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
//display groups
|
category = iter.next();
|
||||||
|
list = categoryMap.get(category);
|
||||||
Iterator<String> iter = categories.iterator();
|
|
||||||
|
if((category != null)&&(category.length() != 0))
|
||||||
out.print("<table class=\"main\" cellspacing=\"10\">");
|
{
|
||||||
while(iter.hasNext())
|
out.print("<fieldset class=\"submenu\">");
|
||||||
{
|
out.print("<legend>");
|
||||||
out.print("<tr><td valign=\"top\" width=\"50%\">");
|
|
||||||
//----------------------------------------------------------------------------------------------------------------------
|
elementBean = ElementManager.getMsg(ctx,category);
|
||||||
|
out.print(elementBean.getName());
|
||||||
category = iter.next();
|
|
||||||
|
out.print("</legend>");
|
||||||
|
}//if
|
||||||
|
|
||||||
|
out.print("<ul>");
|
||||||
|
|
||||||
|
for(MenuItem m : list)
|
||||||
|
{
|
||||||
|
out.print("<li class=\"submenu\">");
|
||||||
|
out.print("<a href='" + m.getMenuLink() + "' class=\"submenu\">");
|
||||||
|
|
||||||
|
elementBean = ElementManager.getMsg(ctx,m.getName());
|
||||||
|
out.print(elementBean.getName());
|
||||||
|
|
||||||
|
out.print("</a>");
|
||||||
|
out.print("</li>");
|
||||||
|
}//for
|
||||||
|
|
||||||
|
out.print("</ul>");
|
||||||
|
|
||||||
|
if((category != null)&&(category.length() != 0))
|
||||||
|
{
|
||||||
|
out.print("</fieldset>");
|
||||||
|
}//if
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------------------------------------------
|
||||||
|
out.print("</td><td valign=\"top\" width=\"50%\">");
|
||||||
|
|
||||||
|
if(!iter.hasNext())
|
||||||
|
{
|
||||||
|
out.print(" ");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//----------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
category = iter.next();
|
||||||
list = categoryMap.get(category);
|
list = categoryMap.get(category);
|
||||||
|
|
||||||
if((category != null)&&(category.length() != 0))
|
if((category != null)&&(category.length() != 0))
|
||||||
{
|
{
|
||||||
out.print("<fieldset class=\"submenu\">");
|
out.print("<fieldset class=\"submenu\">");
|
||||||
out.print("<legend>");
|
out.print("<legend>");
|
||||||
|
|
||||||
elementBean = ElementManager.getMsg(ctx,category);
|
elementBean = ElementManager.getMsg(ctx,category);
|
||||||
out.print(elementBean.getName());
|
out.print(elementBean.getName());
|
||||||
|
|
||||||
out.print("</legend>");
|
out.print("</legend>");
|
||||||
}//if
|
}//if
|
||||||
|
|
||||||
out.print("<ul>");
|
out.print("<ul>");
|
||||||
|
@ -177,11 +201,11 @@ public class MenuAction extends BaseDispatchAction
|
||||||
for(MenuItem m : list)
|
for(MenuItem m : list)
|
||||||
{
|
{
|
||||||
out.print("<li class=\"submenu\">");
|
out.print("<li class=\"submenu\">");
|
||||||
out.print("<a href='" + m.getMenuLink() + "' class=\"submenu\">");
|
out.print("<a href=" + m.getMenuLink() + " class=\"submenu\">");
|
||||||
|
|
||||||
elementBean = ElementManager.getMsg(ctx,m.getName());
|
elementBean = ElementManager.getMsg(ctx,m.getName());
|
||||||
out.print(elementBean.getName());
|
out.print(elementBean.getName());
|
||||||
|
|
||||||
out.print("</a>");
|
out.print("</a>");
|
||||||
out.print("</li>");
|
out.print("</li>");
|
||||||
}//for
|
}//for
|
||||||
|
@ -194,67 +218,18 @@ public class MenuAction extends BaseDispatchAction
|
||||||
}//if
|
}//if
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------------------------
|
||||||
out.print("</td><td valign=\"top\" width=\"50%\">");
|
|
||||||
|
|
||||||
if(!iter.hasNext())
|
}
|
||||||
{
|
out.print("</td></tr>");
|
||||||
out.print(" ");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//----------------------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
category = iter.next();
|
|
||||||
list = categoryMap.get(category);
|
|
||||||
|
|
||||||
if((category != null)&&(category.length() != 0))
|
|
||||||
{
|
|
||||||
out.print("<fieldset class=\"submenu\">");
|
|
||||||
out.print("<legend>");
|
|
||||||
|
|
||||||
elementBean = ElementManager.getMsg(ctx,category);
|
|
||||||
out.print(elementBean.getName());
|
|
||||||
|
|
||||||
out.print("</legend>");
|
|
||||||
}//if
|
|
||||||
|
|
||||||
out.print("<ul>");
|
|
||||||
|
|
||||||
for(MenuItem m : list)
|
|
||||||
{
|
|
||||||
out.print("<li class=\"submenu\">");
|
|
||||||
out.print("<a href=" + m.getMenuLink() + " class=\"submenu\">");
|
|
||||||
|
|
||||||
elementBean = ElementManager.getMsg(ctx,m.getName());
|
|
||||||
out.print(elementBean.getName());
|
|
||||||
|
|
||||||
out.print("</a>");
|
|
||||||
out.print("</li>");
|
|
||||||
}//for
|
|
||||||
|
|
||||||
out.print("</ul>");
|
|
||||||
|
|
||||||
if((category != null)&&(category.length() != 0))
|
|
||||||
{
|
|
||||||
out.print("</fieldset>");
|
|
||||||
}//if
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
}
|
|
||||||
out.print("</td></tr>");
|
|
||||||
}
|
|
||||||
|
|
||||||
out.print("</table>");
|
|
||||||
out.flush();
|
|
||||||
|
|
||||||
String menu = sw.toString();
|
|
||||||
|
|
||||||
request.getSession().setAttribute(Constants.MENU_ITEMS, menu);
|
|
||||||
return mapping.findForward(GET_POS_MENU_ITEMS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return mapping.findForward(GET_MENU_ITEMS);
|
out.print("</table>");
|
||||||
|
out.flush();
|
||||||
|
|
||||||
|
String menu = sw.toString();
|
||||||
|
|
||||||
|
request.getSession().setAttribute(Constants.MENU_ITEMS, menu);
|
||||||
|
return mapping.findForward(GET_POS_MENU_ITEMS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final String INIT_EDIT_LINKSTATUS = "initEditLinkStatus";
|
public static final String INIT_EDIT_LINKSTATUS = "initEditLinkStatus";
|
||||||
|
|
|
@ -1,241 +0,0 @@
|
||||||
/**
|
|
||||||
* Product: Posterita Web-Based POS and Adempiere Plugin
|
|
||||||
* Copyright (C) 2007 Posterita Ltd
|
|
||||||
* This file is part of POSterita
|
|
||||||
*
|
|
||||||
* POSterita is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along
|
|
||||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
* Created on Aug 19, 2005 by praveen
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package org.posterita.struts.product;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
|
|
||||||
import org.apache.struts.action.ActionForm;
|
|
||||||
import org.apache.struts.action.ActionForward;
|
|
||||||
import org.apache.struts.action.ActionMapping;
|
|
||||||
import org.compiere.util.Env;
|
|
||||||
import org.compiere.util.Trx;
|
|
||||||
import org.posterita.Constants;
|
|
||||||
import org.posterita.beans.EditPriceBean;
|
|
||||||
import org.posterita.beans.PriceListBean;
|
|
||||||
import org.posterita.beans.ProductBean;
|
|
||||||
import org.posterita.beans.ProductPriceBean;
|
|
||||||
import org.posterita.businesslogic.ApplicationManager;
|
|
||||||
import org.posterita.businesslogic.PriceListManager;
|
|
||||||
import org.posterita.core.TrxPrefix;
|
|
||||||
import org.posterita.exceptions.ApplicationException;
|
|
||||||
import org.posterita.exceptions.OperationException;
|
|
||||||
import org.posterita.exceptions.SystemException;
|
|
||||||
import org.posterita.form.PriceListForm;
|
|
||||||
import org.posterita.lib.UdiConstants;
|
|
||||||
import org.posterita.struts.core.BaseDispatchAction;
|
|
||||||
import org.posterita.struts.core.DefaultForm;
|
|
||||||
|
|
||||||
public class PriceListAction extends BaseDispatchAction
|
|
||||||
{
|
|
||||||
public static final String INIT_PRICE_LIST = "initPriceList";
|
|
||||||
private Properties webstoreCtx = new Properties();
|
|
||||||
|
|
||||||
|
|
||||||
private Properties getWebstoreContext(HttpServletRequest request)
|
|
||||||
{
|
|
||||||
ApplicationManager.setApplicationParametersInContext(webstoreCtx, "webstore");
|
|
||||||
|
|
||||||
return webstoreCtx;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static final String INIT_WEBSTORE_PRICE_LIST = "initWebstorePriceList";
|
|
||||||
public ActionForward initWebstorePriceList(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws Exception
|
|
||||||
{
|
|
||||||
ActionForward fwd = init(mapping, form, request, response);
|
|
||||||
|
|
||||||
if(fwd!=null)
|
|
||||||
return fwd;
|
|
||||||
|
|
||||||
webstoreCtx = getWebstoreContext(request);
|
|
||||||
|
|
||||||
DefaultForm df = (DefaultForm) form;
|
|
||||||
ProductBean bean = (ProductBean) df.getBean();
|
|
||||||
|
|
||||||
df.setIsWebstoreFeatured("true");
|
|
||||||
|
|
||||||
int priceListId = Env.getContextAsInt(webstoreCtx, UdiConstants.PRICELIST_CTX_PARAM);
|
|
||||||
int priceListVersionId = PriceListManager.getPriceListVersionID(webstoreCtx, priceListId, null);
|
|
||||||
|
|
||||||
ArrayList<ProductPriceBean> productPriceList = new ArrayList<ProductPriceBean> ();
|
|
||||||
|
|
||||||
//if (bean.getSearchText() != null)
|
|
||||||
productPriceList = PriceListManager.getProductPriceList(webstoreCtx, priceListVersionId, bean.getSearchText(), bean.getIsSelfService(), bean.getProductClassification());
|
|
||||||
|
|
||||||
request.getSession().setAttribute(Constants.PRICE_LIST, productPriceList);
|
|
||||||
|
|
||||||
return mapping.findForward(INIT_WEBSTORE_PRICE_LIST);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static final String INIT_EDIT_PRICE_LIST = "initEditPriceList";
|
|
||||||
|
|
||||||
public ActionForward initEditPriceList(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws Exception
|
|
||||||
{
|
|
||||||
ActionForward fwd = init(mapping, form, request, response);
|
|
||||||
|
|
||||||
if(fwd!=null)
|
|
||||||
return fwd;
|
|
||||||
|
|
||||||
DefaultForm df = (DefaultForm) form;
|
|
||||||
|
|
||||||
PriceListBean bean = (PriceListBean) df.getBean();
|
|
||||||
|
|
||||||
request.getSession().setAttribute(Constants.PRODUCT_IDS, bean.getProductIds());
|
|
||||||
|
|
||||||
return mapping.findForward(INIT_EDIT_PRICE_LIST);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final String INIT_EDIT_WSTORE_PRICE_LIST = "initWebstoreEditPriceList";
|
|
||||||
public ActionForward initWebstoreEditPriceList(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws OperationException, ApplicationException
|
|
||||||
{
|
|
||||||
ActionForward fwd = init(mapping, form, request, response);
|
|
||||||
|
|
||||||
if(fwd!=null)
|
|
||||||
return fwd;
|
|
||||||
|
|
||||||
DefaultForm df = (DefaultForm) form;
|
|
||||||
|
|
||||||
PriceListBean bean = (PriceListBean) df.getBean();
|
|
||||||
|
|
||||||
if(bean.getProductIds() == null || bean.getProductIds().length == 0)
|
|
||||||
{
|
|
||||||
postGlobalError("error.product.not.selected", request);
|
|
||||||
return mapping.getInputForward();
|
|
||||||
}
|
|
||||||
|
|
||||||
request.getSession().setAttribute(Constants.PRODUCT_IDS, bean.getProductIds());
|
|
||||||
|
|
||||||
return mapping.findForward(INIT_EDIT_WSTORE_PRICE_LIST);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static final String EDIT_PRICE_LIST = "editPriceList";
|
|
||||||
public ActionForward editPriceLists(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws ApplicationException, OperationException, SystemException
|
|
||||||
{
|
|
||||||
ActionForward fwd = init(mapping, form, request, response);
|
|
||||||
|
|
||||||
if(fwd!=null)
|
|
||||||
return fwd;
|
|
||||||
|
|
||||||
webstoreCtx = getWebstoreContext(request);
|
|
||||||
|
|
||||||
DefaultForm df = (DefaultForm) form;
|
|
||||||
|
|
||||||
EditPriceBean bean = (EditPriceBean) df.getBean();
|
|
||||||
|
|
||||||
BigDecimal priceEntered = new BigDecimal(bean.getPrice().toString());
|
|
||||||
|
|
||||||
Integer productIds[] = (Integer[]) request.getSession().getAttribute(Constants.PRODUCT_IDS);
|
|
||||||
Integer priceListVersionId = (Integer) request.getSession().getAttribute(Constants.PRICE_LIST_VERSION_ID);
|
|
||||||
|
|
||||||
Trx trx = Trx.get(TrxPrefix.getPrefix(), true);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
trx.start();
|
|
||||||
PriceListManager.editProductPrices(webstoreCtx,productIds, priceListVersionId.intValue(), priceEntered, trx.getTrxName());
|
|
||||||
trx.commit();
|
|
||||||
}
|
|
||||||
catch (OperationException e)
|
|
||||||
{
|
|
||||||
trx.rollback();
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
catch (SystemException e)
|
|
||||||
{
|
|
||||||
trx.rollback();
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
trx.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
PriceListForm plf = (PriceListForm) getForm(Constants.PriceListForm, Constants.InitPriceListAction, request);
|
|
||||||
|
|
||||||
PriceListBean plBean = new PriceListBean();
|
|
||||||
plBean.setPriceListVersionId(priceListVersionId);
|
|
||||||
plf.populate(plBean);
|
|
||||||
|
|
||||||
return mapping.findForward(EDIT_PRICE_LIST);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final String EDIT_WEBSTORE_PRICELIST = "editWebstorePriceList";
|
|
||||||
public ActionForward editWebstorePriceList(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws OperationException, ApplicationException, SystemException
|
|
||||||
{
|
|
||||||
ActionForward fwd = init(mapping, form, request, response);
|
|
||||||
|
|
||||||
if(fwd!=null)
|
|
||||||
return fwd;
|
|
||||||
|
|
||||||
webstoreCtx = getWebstoreContext(request);
|
|
||||||
|
|
||||||
DefaultForm df = (DefaultForm) form;
|
|
||||||
|
|
||||||
EditPriceBean bean = (EditPriceBean) df.getBean();
|
|
||||||
|
|
||||||
Integer productIds[] = (Integer[])request.getSession().getAttribute(Constants.PRODUCT_IDS);
|
|
||||||
|
|
||||||
int priceListId = Env.getContextAsInt(webstoreCtx, UdiConstants.PRICELIST_CTX_PARAM);
|
|
||||||
int priceListVersionId = PriceListManager.getPriceListVersionID(webstoreCtx, priceListId, null);
|
|
||||||
|
|
||||||
BigDecimal priceEntered = new BigDecimal(bean.getPrice().toString());
|
|
||||||
|
|
||||||
Trx trx = Trx.get(TrxPrefix.getPrefix(), true);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
trx.start();
|
|
||||||
PriceListManager.editProductPrices(webstoreCtx,productIds, priceListVersionId, priceEntered, trx.getTrxName());
|
|
||||||
trx.commit();
|
|
||||||
}
|
|
||||||
catch (OperationException e)
|
|
||||||
{
|
|
||||||
trx.rollback();
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
catch (SystemException e)
|
|
||||||
{
|
|
||||||
trx.rollback();
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
trx.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return mapping.findForward(EDIT_WEBSTORE_PRICELIST);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -31,7 +31,7 @@
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
|
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
|
||||||
<title>POSterita</title>
|
<title>POSterita:. Create Client</title>
|
||||||
<link type="text/css" href="css/newPOS.jsp" rel="stylesheet">
|
<link type="text/css" href="css/newPOS.jsp" rel="stylesheet">
|
||||||
<link type="text/css" href="css/common.jsp" rel="stylesheet">
|
<link type="text/css" href="css/common.jsp" rel="stylesheet">
|
||||||
<link rel="shortcut icon" href="images/posterita.jpg" type="image/jpg" />
|
<link rel="shortcut icon" href="images/posterita.jpg" type="image/jpg" />
|
||||||
|
@ -80,7 +80,7 @@
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
|
|
||||||
<html:form action="/ClientAction">
|
<html:form action="/ClientAction" method="post" enctype="multipart/form-data">
|
||||||
<html:hidden property="action" value="createClient"/>
|
<html:hidden property="action" value="createClient"/>
|
||||||
<%@ include file="/jsp/include/errors.jsp" %>
|
<%@ include file="/jsp/include/errors.jsp" %>
|
||||||
<table>
|
<table>
|
||||||
|
@ -164,7 +164,15 @@
|
||||||
</TR>
|
</TR>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
|
<fieldset>
|
||||||
|
<legend><font class="title">Accounting</font></legend>
|
||||||
|
<table width="100%" border="0" class="display">
|
||||||
|
<tr>
|
||||||
|
<td>Load Accounting Values</td>
|
||||||
|
<td><html:file value="" property="file"/></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</fieldset>
|
||||||
</td>
|
</td>
|
||||||
<td align="right">
|
<td align="right">
|
||||||
<html:button property="button" styleClass="save smallbutton" onclick="newsubmit(this)" tabindex="10" accesskey="s">
|
<html:button property="button" styleClass="save smallbutton" onclick="newsubmit(this)" tabindex="10" accesskey="s">
|
||||||
|
@ -172,8 +180,7 @@
|
||||||
</html:button>
|
</html:button>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
</html:form>
|
</html:form>
|
||||||
|
|
||||||
<SCRIPT>
|
<SCRIPT>
|
||||||
|
|
Loading…
Reference in New Issue