/** * Get Menu tree that directly enter "create new" mode * * @return menu as array list */ public ArrayList<CTreeNode> getMenuCreateNew() { MUser user = MUser.get(getContext()); int AD_Tree_ID = user.getAD_Tree_MenuNew_ID(); if (AD_Tree_ID == 0) // create new has not yet been created return new ArrayList<CTreeNode>(); return getMenuTree(AD_Tree_ID, false); } // getMenuCreateNew
/** * Get Menu favorites for a user * * @return menu as array list */ public ArrayList<CTreeNode> getMenuFavorites() { MUser user = MUser.get(getContext()); int AD_Tree_ID = user.getAD_Tree_MenuFavorite_ID(); if (AD_Tree_ID == 0) // favorites has not yet been created return new ArrayList<CTreeNode>(); return getMenuTree(AD_Tree_ID, false); } // get favorites menu
/** * Make create new add/remove persistent ("bar" in swing client) * * @param add true if add - otherwise remove * @param Node_ID Node ID * @return true if updated */ public boolean updateCreateNew(boolean add, int Node_ID) { /* * Code logic now uses MUser to store favorites. TODO: * VTreePanel.barDBupdate should be similarly updated or deprecated for * Swing client. */ MUser user = MUser.get(getContext()); return user.addUserMenuNewFavorite(Node_ID, 0); } // updateCreateNew
public Boolean savePreferences(Map<String, String> ctx) { CContext cContext = getContext(); MUser user = MUser.get(cContext); MUserPreference preference = user.getPreference(); String printerName = ctx.get("PrinterName"); if (printerName != null && printerName.trim().equalsIgnoreCase("")) { cContext.setPrinterName(printerName); preference.setPrinterName(printerName); } String autoCommit = ctx.get("AutoCommit"); if (autoCommit != null) { cContext.setAutoCommit(autoCommit.trim().equalsIgnoreCase("Y")); preference.setIsAutoCommit(autoCommit.trim().equalsIgnoreCase("Y")); } String showAdvanced = ctx.get("#ShowAdvanced"); if (showAdvanced != null) { cContext.setContext("#ShowAdvanced", showAdvanced); preference.setIsShowAdvanced(showAdvanced.trim().equalsIgnoreCase("Y")); } String showAccounting = ctx.get("#ShowAcct"); if (showAccounting != null) { cContext.setContext("#ShowAcct", showAccounting); preference.setIsShowAcct(showAccounting.trim().equalsIgnoreCase("Y")); } String showTranslation = ctx.get("#ShowTrl"); if (showTranslation != null) { cContext.setContext("#ShowTrl", showTranslation); preference.setIsShowTrl(showTranslation.trim().equalsIgnoreCase("Y")); } String uiTheme = ctx.get("#UITheme"); if (uiTheme != null && !uiTheme.trim().equalsIgnoreCase("")) { cContext.setContext("#UITheme", uiTheme); preference.setUITheme(uiTheme); } String printPreview = ctx.get("#PrintPreview"); if (printPreview != null) { cContext.setPrintPreview(printPreview.equalsIgnoreCase("Y")); Ini.setProperty(Ini.P_PRINTPREVIEW, printPreview.equalsIgnoreCase("Y")); Ini.saveProperties(Ini.isClient()); } String date = ctx.get("#Date"); cContext.setContext("#Date", date); return preference.save(); }
@Override public void actionPerformed(ActionEvent e) { if (e.getSource().equals(bProcess)) { MUser.get(posPanel.getCtx(), username.getText(), pin.getText()); } dispose(); }
/** * Notify users * * @param users AD_User_ID list * @param subject email subject * @param message email message * @param attachments * @return how many email were sent */ private int notifyUsers( Collection<Integer> users, String subject, String message, Collection<File> attachments) { int countMail = 0; for (int user_id : users) { MUser user = MUser.get(getCtx(), user_id); if (user.isNotificationEMail()) { if (m_client.sendEMailAttachments(user_id, subject, message, attachments)) { countMail++; } } if (user.isNotificationNote()) { Trx trx = null; try { trx = Trx.get(Trx.createTrxName("AP_NU"), true); // Notice int AD_Message_ID = 52244; /* TODO - Hardcoded message=notes */ MNote note = new MNote(getCtx(), AD_Message_ID, user_id, trx.getTrxName()); note.setClientOrg(m_model.getAD_Client_ID(), m_model.getAD_Org_ID()); note.setTextMsg(message); note.saveEx(); // Attachment MAttachment attachment = new MAttachment(getCtx(), MNote.Table_ID, note.getAD_Note_ID(), trx.getTrxName()); for (File f : attachments) { attachment.addEntry(f); } attachment.setTextMsg(message); attachment.saveEx(); countMail++; trx.commit(); } catch (Throwable e) { if (trx != null) trx.rollback(); } finally { if (trx != null) trx.close(); } } } return countMail; }
/** * Perform process. * * @return Message * @throws Exception if not successful */ protected String doIt() throws Exception { String where = " Password IS NOT NULL AND Salt IS NULL "; int count = 0; boolean isEncrypted = MColumn.isEncrypted(417); List<MUser> users = MTable.get(getCtx(), MUser.Table_ID).createQuery(where, get_TrxName()).list(); for (MUser user : users) { if (user.getAD_User_ID() == 0) { String password = DB.getSQLValueString( get_TrxName(), "SELECT Password FROM AD_User WHERE AD_User_ID=?", 0); if (isEncrypted) password = SecureEngine.decrypt(password); user.setPassword(password); String sql = "UPDATE AD_User SET Updated=SysDate, UpdatedBy=" + getAD_User_ID(); if (!Util.isEmpty(password)) { sql += ", Password="******", Salt=" + DB.TO_STRING(user.getSalt()); } sql += " WHERE AD_User_ID=0"; DB.executeUpdateEx(sql, get_TrxName()); count++; } else { user.setPassword(user.getPassword()); count++; user.saveEx(); } } return "@Updated@ " + count; } // doIt
/** * Update of user favorites for a user with specified ordering for favorites * * @param menuIDs List<Integer> ordered list of menuIDs to put in the tree * @return true if updated */ public boolean updateCreateNew(List<Integer> menuIDs) { MUser user = MUser.get(getContext()); MTree menuTree = null; if ((menuTree = user.getUserNewFavoriteTree()) == null) return false; return updateUserTree(menuIDs, menuTree); } // updateCreateNew