Search in sources :

Example 1 with Language

use of org.compiere.util.Language in project adempiere by adempiere.

the class WLogin method createFirstPage.

/**************************************************************************
	 *  First Login Page
	 *  @param cProp Login Cookie information for defaults
	 *  @param request request
	 *  @param errorMessage error message
	 *  @return WDoc page
	 */
private WebDoc createFirstPage(Properties cProp, HttpServletRequest request, String errorMessage) {
    log.info(" - " + errorMessage);
    String AD_Language = (cProp.getProperty(Env.LANGUAGE, Language.getAD_Language(request.getLocale())));
    //
    String windowTitle = Msg.getMsg(AD_Language, "Login");
    String usrText = Msg.getMsg(AD_Language, "User");
    String pwdText = Msg.getMsg(AD_Language, "Password");
    String lngText = Msg.translate(AD_Language, "AD_Language");
    String okText = Msg.getMsg(AD_Language, "OK");
    String cancelText = Msg.getMsg(AD_Language, "Cancel");
    String storeTxt = Msg.getMsg(AD_Language, "SaveCookie");
    //	Form - post to same URL
    String action = request.getRequestURI();
    form myForm = null;
    myForm = new form(action).setName("Login1");
    table table = new table().setAlign(AlignType.CENTER).setWidth("25%");
    //Modified by Rob Klein 4/29/07
    //	Blank Line
    tr line = new tr();
    line.addElement(new td().addElement(" "));
    //	Username
    String userData = cProp.getProperty(P_USERNAME, "");
    line = new tr();
    label usrLabel = new label().setFor(P_USERNAME + "F").addElement(usrText);
    usrLabel.setID(P_USERNAME + "L");
    line.addElement(new td().addElement(usrLabel).setAlign(AlignType.RIGHT));
    input usr = new input(input.TYPE_TEXT, P_USERNAME, userData).setSize(20).setMaxlength(30);
    usr.setID(P_USERNAME + "F");
    line.addElement(new td().addElement(usr).setAlign(AlignType.LEFT));
    table.addElement(line);
    //  Password
    String pwdData = cProp.getProperty(P_PASSWORD, "");
    line = new tr();
    label pwdLabel = new label().setFor(P_PASSWORD + "F").addElement(pwdText);
    pwdLabel.setID(P_PASSWORD + "L");
    line.addElement(new td().addElement(pwdLabel).setAlign(AlignType.RIGHT));
    input pwd = new input(input.TYPE_PASSWORD, P_PASSWORD, pwdData).setSize(20).setMaxlength(30);
    pwd.setID(P_PASSWORD + "F");
    line.addElement(new td().addElement(pwd).setAlign(AlignType.LEFT));
    table.addElement(line);
    //	Language Pick
    String langData = cProp.getProperty(AD_Language);
    line = new tr();
    label langLabel = new label().setFor(Env.LANGUAGE + "F").addElement(lngText);
    langLabel.setID(Env.LANGUAGE + "L");
    line.addElement(new td().addElement(langLabel).setAlign(AlignType.RIGHT));
    option[] options = new option[Language.getLanguageCount()];
    for (int i = 0; i < Language.getLanguageCount(); i++) {
        Language language = Language.getLanguage(i);
        options[i] = new option(language.getAD_Language()).addElement(Util.maskHTML(language.getName()));
        if (language.getAD_Language().equals(langData))
            options[i].setSelected(true);
        else
            options[i].setSelected(false);
    }
    line.addElement(new td().addElement(new select(Env.LANGUAGE, options).setID(Env.LANGUAGE + "F")));
    table.addElement(line);
    //  Store Cookie
    String storeData = cProp.getProperty(P_STORE, "N");
    line = new tr();
    line.addElement(new td());
    input store = new input(input.TYPE_CHECKBOX, P_STORE, "Y").addElement(storeTxt).setChecked(storeData.equals("Y"));
    store.setID(P_STORE + "F");
    line.addElement(new td().addElement(store).setAlign(AlignType.LEFT));
    table.addElement(line);
    //  ErrorMessage
    if (errorMessage != null && errorMessage.length() > 0) {
        line = new tr();
        //	line.addElement(new td());
        line.addElement(new td().setColSpan(2).addElement(//  color, size
        new font(HtmlColor.red, 4).addElement(new b(errorMessage))));
        table.addElement(line);
    }
    //  Finish
    line = new tr();
    //Modified by Rob Klein 4/29/07
    table tablebutton = new table().setAlign(AlignType.CENTER).setWidth("25%");
    input cancel = new input(input.TYPE_RESET, "Reset", "  " + "Cancel");
    cancel.setClass("cancelbtn");
    line.addElement(new td().addElement(cancel).setWidth("50%")).setAlign(AlignType.CENTER);
    input submit = new input(input.TYPE_SUBMIT, P_SUBMIT, "  " + "OK");
    submit.setClass("loginbtn");
    line.addElement(new td().addElement(submit).setWidth("50%").setAlign(AlignType.CENTER));
    tablebutton.addElement(line);
    table.addElement(tablebutton);
    //
    myForm.addElement(table);
    //  Document
    WebDoc doc = WebDoc.createWindow(windowTitle);
    //Modified by Rob Klein 4/29/07
    img img = new img(WebEnv.getImageDirectory("Logo.gif"), "logo");
    doc.addWindowCenter(true).addElement(img).addElement(new p()).addElement(new p()).addElement(myForm).addElement(new p()).addElement(new p());
    //  Clear Menu Frame
    doc.getBody().addElement(WebUtil.getClearFrame(WebEnv.TARGET_MENU)).setTitle(windowTitle);
    return doc;
}
Also used : org.apache.ecs.xhtml.b(org.apache.ecs.xhtml.b) org.apache.ecs.xhtml.img(org.apache.ecs.xhtml.img) org.apache.ecs.xhtml.select(org.apache.ecs.xhtml.select) org.apache.ecs.xhtml.label(org.apache.ecs.xhtml.label) org.apache.ecs.xhtml.td(org.apache.ecs.xhtml.td) org.apache.ecs.xhtml.p(org.apache.ecs.xhtml.p) org.apache.ecs.xhtml.input(org.apache.ecs.xhtml.input) org.apache.ecs.xhtml.form(org.apache.ecs.xhtml.form) Language(org.compiere.util.Language) WebDoc(org.compiere.util.WebDoc) org.apache.ecs.xhtml.table(org.apache.ecs.xhtml.table) org.apache.ecs.xhtml.tr(org.apache.ecs.xhtml.tr) org.apache.ecs.xhtml.option(org.apache.ecs.xhtml.option) org.apache.ecs.xhtml.font(org.apache.ecs.xhtml.font)

Example 2 with Language

use of org.compiere.util.Language in project adempiere by adempiere.

the class ReportEngine method get.

/**************************************************************************
	 * 	Get Document Print Engine for Document Type.
	 * 	@param ctx context
	 * 	@param type document type
	 * 	@param Record_ID id
	 *  @param trxName
	 * 	@return Report Engine or null
	 */
public static ReportEngine get(Properties ctx, int type, int Record_ID, String trxName) {
    if (Record_ID < 1) {
        log.log(Level.WARNING, "No PrintFormat for Record_ID=" + Record_ID + ", Type=" + type);
        return null;
    }
    //	Order - Print Shipment or Invoice
    if (type == ORDER) {
        int[] what = getDocumentWhat(Record_ID);
        if (what != null) {
            type = what[0];
            Record_ID = what[1];
        }
    }
    //	Order
    int AD_PrintFormat_ID = 0;
    int C_BPartner_ID = 0;
    String DocumentNo = null;
    int copies = 1;
    //	Language
    MClient client = MClient.get(ctx);
    Language language = client.getLanguage();
    //	Get Document Info
    String sql = null;
    if (type == CHECK)
        sql = //	1
        "SELECT bad.Check_PrintFormat_ID," + //	2..5
        "	c.IsMultiLingualDocument,bp.AD_Language,bp.C_BPartner_ID,d.DocumentNo " + "FROM C_PaySelectionCheck d" + " INNER JOIN C_PaySelection ps ON (d.C_PaySelection_ID=ps.C_PaySelection_ID)" + " INNER JOIN C_BankAccountDoc bad ON (ps.C_BankAccount_ID=bad.C_BankAccount_ID AND d.PaymentRule=bad.PaymentRule)" + " INNER JOIN AD_Client c ON (d.AD_Client_ID=c.AD_Client_ID)" + " INNER JOIN C_BPartner bp ON (d.C_BPartner_ID=bp.C_BPartner_ID) " + //	info from BankAccount
        "WHERE d.C_PaySelectionCheck_ID=?";
    else if (type == HR_CHECK)
        sql = //	1
        "SELECT bad.Check_PrintFormat_ID," + //	2..5
        "	c.IsMultiLingualDocument,bp.AD_Language,bp.C_BPartner_ID,d.DocumentNo " + "FROM HR_PaySelectionCheck d" + " INNER JOIN HR_PaySelection ps ON (d.HR_PaySelection_ID=ps.HR_PaySelection_ID)" + " INNER JOIN C_BankAccountDoc bad ON (ps.C_BankAccount_ID=bad.C_BankAccount_ID AND d.PaymentRule=bad.PaymentRule)" + " INNER JOIN AD_Client c ON (d.AD_Client_ID=c.AD_Client_ID)" + " INNER JOIN C_BPartner bp ON (d.C_BPartner_ID=bp.C_BPartner_ID) " + //	info from BankAccount
        "WHERE d.HR_PaySelectionCheck_ID=?";
    else if (type == DUNNING)
        sql = "SELECT dl.Dunning_PrintFormat_ID," + " c.IsMultiLingualDocument,bp.AD_Language,bp.C_BPartner_ID,dr.DunningDate " + "FROM C_DunningRunEntry d" + " INNER JOIN AD_Client c ON (d.AD_Client_ID=c.AD_Client_ID)" + " INNER JOIN C_BPartner bp ON (d.C_BPartner_ID=bp.C_BPartner_ID)" + " INNER JOIN C_DunningRun dr ON (d.C_DunningRun_ID=dr.C_DunningRun_ID)" + " INNER JOIN C_DunningLevel dl ON (dl.C_DunningLevel_ID=d.C_DunningLevel_ID) " + //	info from Dunning
        "WHERE d.C_DunningRunEntry_ID=?";
    else if (type == REMITTANCE)
        sql = "SELECT pf.Remittance_PrintFormat_ID," + " c.IsMultiLingualDocument,bp.AD_Language,bp.C_BPartner_ID,d.DocumentNo " + "FROM C_PaySelectionCheck d" + " INNER JOIN AD_Client c ON (d.AD_Client_ID=c.AD_Client_ID)" + " INNER JOIN AD_PrintForm pf ON (c.AD_Client_ID=pf.AD_Client_ID)" + " INNER JOIN C_BPartner bp ON (d.C_BPartner_ID=bp.C_BPartner_ID) " + //	info from PrintForm
        "WHERE d.C_PaySelectionCheck_ID=?" + " AND pf.AD_Org_ID IN (0,d.AD_Org_ID) ORDER BY pf.AD_Org_ID DESC";
    else if (type == HR_REMITTANCE)
        sql = "SELECT pf.Remittance_PrintFormat_ID," + " c.IsMultiLingualDocument,bp.AD_Language,bp.C_BPartner_ID,d.DocumentNo " + "FROM HR_PaySelectionCheck d" + " INNER JOIN AD_Client c ON (d.AD_Client_ID=c.AD_Client_ID)" + " INNER JOIN AD_PrintForm pf ON (c.AD_Client_ID=pf.AD_Client_ID)" + " INNER JOIN C_BPartner bp ON (d.C_BPartner_ID=bp.C_BPartner_ID) " + //	info from PrintForm
        "WHERE d.HR_PaySelectionCheck_ID=?" + " AND pf.AD_Org_ID IN (0,d.AD_Org_ID) ORDER BY pf.AD_Org_ID DESC";
    else if (type == PROJECT)
        sql = "SELECT pf.Project_PrintFormat_ID," + " c.IsMultiLingualDocument,bp.AD_Language,bp.C_BPartner_ID,d.Value " + "FROM C_Project d" + " INNER JOIN AD_Client c ON (d.AD_Client_ID=c.AD_Client_ID)" + " INNER JOIN AD_PrintForm pf ON (c.AD_Client_ID=pf.AD_Client_ID)" + " LEFT OUTER JOIN C_BPartner bp ON (d.C_BPartner_ID=bp.C_BPartner_ID) " + //	info from PrintForm
        "WHERE d.C_Project_ID=?" + " AND pf.AD_Org_ID IN (0,d.AD_Org_ID) ORDER BY pf.AD_Org_ID DESC";
    else if (type == MANUFACTURING_ORDER)
        sql = "SELECT pf.Manuf_Order_PrintFormat_ID," + " c.IsMultiLingualDocument,bp.AD_Language, 0 , d.DocumentNo " + "FROM PP_Order d" + " INNER JOIN AD_Client c ON (d.AD_Client_ID=c.AD_Client_ID)" + " LEFT OUTER JOIN AD_User u ON (u.AD_User_ID=d.Planner_ID)" + " LEFT OUTER JOIN C_BPartner bp ON (u.C_BPartner_ID=bp.C_BPartner_ID) " + " INNER JOIN AD_PrintForm pf ON (c.AD_Client_ID=pf.AD_Client_ID)" + //	info from PrintForm
        "WHERE d.PP_Order_ID=?" + " AND pf.AD_Org_ID IN (0,d.AD_Org_ID) ORDER BY pf.AD_Org_ID DESC";
    else if (type == DISTRIBUTION_ORDER)
        sql = "SELECT pf.Distrib_Order_PrintFormat_ID," + " c.IsMultiLingualDocument,bp.AD_Language, bp.C_BPartner_ID , d.DocumentNo " + "FROM DD_Order d" + " INNER JOIN AD_Client c ON (d.AD_Client_ID=c.AD_Client_ID)" + " INNER JOIN AD_PrintForm pf ON (c.AD_Client_ID=pf.AD_Client_ID)" + " LEFT OUTER JOIN C_BPartner bp ON (d.C_BPartner_ID=bp.C_BPartner_ID) " + //	info from PrintForm
        "WHERE d.DD_Order_ID=?" + " AND pf.AD_Org_ID IN (0,d.AD_Org_ID) ORDER BY pf.AD_Org_ID DESC";
    else if (type == RFQ)
        sql = "SELECT COALESCE(t.AD_PrintFormat_ID, pf.AD_PrintFormat_ID)," + " c.IsMultiLingualDocument,bp.AD_Language,bp.C_BPartner_ID,rr.Name " + "FROM C_RfQResponse rr" + " INNER JOIN C_RfQ r ON (rr.C_RfQ_ID=r.C_RfQ_ID)" + " INNER JOIN C_RfQ_Topic t ON (r.C_RfQ_Topic_ID=t.C_RfQ_Topic_ID)" + " INNER JOIN AD_Client c ON (rr.AD_Client_ID=c.AD_Client_ID)" + " INNER JOIN C_BPartner bp ON (rr.C_BPartner_ID=bp.C_BPartner_ID)," + " AD_PrintFormat pf " + "WHERE pf.AD_Client_ID IN (0,rr.AD_Client_ID)" + //	from RfQ PrintFormat
        " AND pf.AD_Table_ID=725 AND pf.IsTableBased='N'" + //	Info from RfQTopic
        " AND rr.C_RfQResponse_ID=? " + "ORDER BY t.AD_PrintFormat_ID, pf.AD_Client_ID DESC, pf.AD_Org_ID DESC";
    else // Fix [2574162] Priority to choose invoice print format not working
    if (type == ORDER || type == INVOICE)
        sql = //	1..2
        "SELECT pf.Order_PrintFormat_ID,pf.Shipment_PrintFormat_ID," + //	Prio: 1. BPartner 2. DocType, 3. PrintFormat (Org)	//	see InvoicePrint
        " COALESCE (bp.Invoice_PrintFormat_ID,dt.AD_PrintFormat_ID,pf.Invoice_PrintFormat_ID)," + // 3
        " pf.Project_PrintFormat_ID, pf.Remittance_PrintFormat_ID," + //	4..5
        " c.IsMultiLingualDocument, bp.AD_Language," + //	6..7
        " COALESCE(dt.DocumentCopies,0)+COALESCE(bp.DocumentCopies,1), " + // 	8
        " dt.AD_PrintFormat_ID,bp.C_BPartner_ID,d.DocumentNo " + //	9..11
        "FROM " + DOC_BASETABLES[type] + " d" + " INNER JOIN AD_Client c ON (d.AD_Client_ID=c.AD_Client_ID)" + " INNER JOIN AD_PrintForm pf ON (c.AD_Client_ID=pf.AD_Client_ID)" + " INNER JOIN C_BPartner bp ON (d.C_BPartner_ID=bp.C_BPartner_ID)" + " LEFT OUTER JOIN C_DocType dt ON ((d.C_DocType_ID>0 AND d.C_DocType_ID=dt.C_DocType_ID) OR (d.C_DocType_ID=0 AND d.C_DocTypeTarget_ID=dt.C_DocType_ID)) " + "WHERE d." + DOC_IDS[type] + //	info from PrintForm
        "=?" + " AND pf.AD_Org_ID IN (0,d.AD_Org_ID) " + "ORDER BY pf.AD_Org_ID DESC";
    else
        //	Get PrintFormat from Org or 0 of document client
        sql = //	1..2
        "SELECT pf.Order_PrintFormat_ID,pf.Shipment_PrintFormat_ID," + //	Prio: 1. BPartner 2. DocType, 3. PrintFormat (Org)	//	see InvoicePrint
        " COALESCE (bp.Invoice_PrintFormat_ID,dt.AD_PrintFormat_ID,pf.Invoice_PrintFormat_ID)," + // 3
        " pf.Project_PrintFormat_ID, pf.Remittance_PrintFormat_ID," + //	4..5
        " c.IsMultiLingualDocument, bp.AD_Language," + //	6..7
        " COALESCE(dt.DocumentCopies,0)+COALESCE(bp.DocumentCopies,1), " + // 	8
        " dt.AD_PrintFormat_ID,bp.C_BPartner_ID,d.DocumentNo, " + //  9..11 
        " pf.Manuf_Order_PrintFormat_ID, pf.Distrib_Order_PrintFormat_ID " + //	12..13
        "FROM " + DOC_BASETABLES[type] + " d" + " INNER JOIN AD_Client c ON (d.AD_Client_ID=c.AD_Client_ID)" + " INNER JOIN AD_PrintForm pf ON (c.AD_Client_ID=pf.AD_Client_ID)" + " INNER JOIN C_BPartner bp ON (d.C_BPartner_ID=bp.C_BPartner_ID)" + " LEFT OUTER JOIN C_DocType dt ON (d.C_DocType_ID=dt.C_DocType_ID) " + "WHERE d." + DOC_IDS[type] + //	info from PrintForm
        "=?" + " AND pf.AD_Org_ID IN (0,d.AD_Org_ID) " + "ORDER BY pf.AD_Org_ID DESC";
    //
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    try {
        pstmt = DB.prepareStatement(sql, trxName);
        pstmt.setInt(1, Record_ID);
        rs = pstmt.executeQuery();
        if (//	first record only
        rs.next()) {
            if (type == CHECK || type == HR_CHECK || type == DUNNING || type == REMITTANCE || type == HR_REMITTANCE || type == PROJECT || type == RFQ || type == MANUFACTURING_ORDER || type == DISTRIBUTION_ORDER) {
                AD_PrintFormat_ID = rs.getInt(1);
                copies = 1;
                //	Set Language when enabled
                String AD_Language = rs.getString(3);
                if (// && "Y".equals(rs.getString(2)))	//	IsMultiLingualDocument
                AD_Language != null)
                    language = Language.getLanguage(AD_Language);
                C_BPartner_ID = rs.getInt(4);
                if (type == DUNNING) {
                    Timestamp ts = rs.getTimestamp(5);
                    DocumentNo = ts.toString();
                } else
                    DocumentNo = rs.getString(5);
            } else {
                //	Set PrintFormat
                AD_PrintFormat_ID = rs.getInt(type + 1);
                if (//	C_DocType.AD_PrintFormat_ID
                type != INVOICE && rs.getInt(9) != 0)
                    AD_PrintFormat_ID = rs.getInt(9);
                copies = rs.getInt(8);
                //	Set Language when enabled
                String AD_Language = rs.getString(7);
                if (// && "Y".equals(rs.getString(6)))	//	IsMultiLingualDocument
                AD_Language != null)
                    language = Language.getLanguage(AD_Language);
                C_BPartner_ID = rs.getInt(10);
                DocumentNo = rs.getString(11);
            }
        }
    } catch (Exception e) {
        log.log(Level.SEVERE, "Record_ID=" + Record_ID + ", SQL=" + sql, e);
    } finally {
        DB.close(rs, pstmt);
        rs = null;
        pstmt = null;
    }
    if (AD_PrintFormat_ID == 0) {
        log.log(Level.SEVERE, "No PrintFormat found for Type=" + type + ", Record_ID=" + Record_ID);
        return null;
    }
    //	Get Format & Data
    MPrintFormat format = MPrintFormat.get(ctx, AD_PrintFormat_ID, false);
    //	BP Language if Multi-Lingual
    format.setLanguage(language);
    //	if (!Env.isBaseLanguage(language, DOC_TABLES[type]))
    format.setTranslationLanguage(language);
    //	query
    MQuery query = new MQuery(format.getAD_Table_ID());
    query.addRestriction(DOC_IDS[type], MQuery.EQUAL, Record_ID);
    //
    if (DocumentNo == null || DocumentNo.length() == 0)
        DocumentNo = "DocPrint";
    PrintInfo info = new PrintInfo(DocumentNo, DOC_TABLE_ID[type], Record_ID, C_BPartner_ID);
    info.setCopies(copies);
    //	true prints "Copy" on second
    info.setDocumentCopy(false);
    info.setPrinterName(format.getPrinterName());
    //	Engine
    ReportEngine re = new ReportEngine(ctx, format, query, info, trxName);
    return re;
}
Also used : PreparedStatement(java.sql.PreparedStatement) MQuery(org.compiere.model.MQuery) PrintInfo(org.compiere.model.PrintInfo) Timestamp(java.sql.Timestamp) FileNotFoundException(java.io.FileNotFoundException) SQLException(java.sql.SQLException) IOException(java.io.IOException) MClient(org.compiere.model.MClient) Language(org.compiere.util.Language) ResultSet(java.sql.ResultSet)

Example 3 with Language

use of org.compiere.util.Language in project adempiere by adempiere.

the class ReportEngine method createHTML.

/**************************************************************************
	 * 	Create HTML File
	 * 	@param file file
	 *  @param onlyTable if false create complete HTML document
	 *  @param language optional language - if null the default language is used to format nubers/dates
	 *  @param extension optional extension for html output
	 * 	@return true if success
	 */
public boolean createHTML(File file, boolean onlyTable, Language language, IHTMLExtension extension) {
    try {
        Language lang = language;
        if (lang == null)
            lang = Language.getLoginLanguage();
        // teo_sarca: save using adempiere charset [ 1658127 ]
        Writer fw = new OutputStreamWriter(new FileOutputStream(file, false), Ini.getCharset());
        return createHTML(new BufferedWriter(fw), onlyTable, lang, extension);
    } catch (FileNotFoundException fnfe) {
        log.log(Level.SEVERE, "(f) - " + fnfe.toString());
    } catch (Exception e) {
        log.log(Level.SEVERE, "(f)", e);
    }
    return false;
}
Also used : Language(org.compiere.util.Language) FileOutputStream(java.io.FileOutputStream) FileNotFoundException(java.io.FileNotFoundException) OutputStreamWriter(java.io.OutputStreamWriter) PrintWriter(java.io.PrintWriter) Writer(java.io.Writer) OutputStreamWriter(java.io.OutputStreamWriter) BufferedWriter(java.io.BufferedWriter) FileNotFoundException(java.io.FileNotFoundException) SQLException(java.sql.SQLException) IOException(java.io.IOException) BufferedWriter(java.io.BufferedWriter)

Example 4 with Language

use of org.compiere.util.Language in project adempiere by adempiere.

the class PayPrint method loadPaymentRule.

//  loadPaySelectInfo
/**
	 *  Bank changed - load PaymentRule
	 */
public ArrayList<ValueNamePair> loadPaymentRule(int paySelectionId) {
    ArrayList<ValueNamePair> data = new ArrayList<ValueNamePair>();
    // load PaymentRule for Bank
    //  MLookupInfo.getAD_Reference_ID("All_Payment Rule");
    int AD_Reference_ID = 195;
    Language language = Language.getLanguage(Env.getAD_Language(Env.getCtx()));
    MLookupInfo info = MLookupFactory.getLookup_List(language, AD_Reference_ID);
    String sql = info.Query.substring(0, info.Query.indexOf(" ORDER BY")) + " AND " + info.KeyColumn + " IN (SELECT PaymentRule FROM C_PaySelectionCheck WHERE C_PaySelection_ID=?) " + info.Query.substring(info.Query.indexOf(" ORDER BY"));
    try {
        PreparedStatement pstmt = DB.prepareStatement(sql, null);
        pstmt.setInt(1, paySelectionId);
        ResultSet rs = pstmt.executeQuery();
        //
        while (rs.next()) {
            ValueNamePair pp = new ValueNamePair(rs.getString(2), rs.getString(3));
            data.add(pp);
        }
        rs.close();
        pstmt.close();
    } catch (SQLException e) {
        log.log(Level.SEVERE, sql, e);
    }
    if (data.size() == 0)
        log.config("PaySel=" + paySelectionId + ", BAcct=" + bankAccountId + " - " + sql);
    return data;
}
Also used : MLookupInfo(org.compiere.model.MLookupInfo) Language(org.compiere.util.Language) SQLException(java.sql.SQLException) ArrayList(java.util.ArrayList) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) ValueNamePair(org.compiere.util.ValueNamePair)

Example 5 with Language

use of org.compiere.util.Language in project adempiere by adempiere.

the class VMRPDetailed method statInit.

/**
	 * Static Setup - add fields to parameterPanel
	 * @throws Exception if Lookups cannot be initialized
	 */
private void statInit() throws Exception {
    // Resource Lookup
    // Base Language
    Language language = Language.getLoginLanguage();
    MLookup resourceL = MLookupFactory.get(getCtx(), p_WindowNo, MColumn.getColumn_ID(MResource.Table_Name, MResource.COLUMNNAME_S_Resource_ID), DisplayType.TableDir, language, MResource.COLUMNNAME_S_Resource_ID, 0, false, MResource.Table_Name + "." + MResource.COLUMNNAME_ManufacturingResourceType + "= '" + MResource.MANUFACTURINGRESOURCETYPE_Plant + "'");
    fResource_ID = new VLookup(MPPMRP.COLUMNNAME_S_Resource_ID, false, false, true, resourceL) {

        private static final long serialVersionUID = 1L;

        public void setValue(Object arg0) {
            super.setValue(arg0);
        }

        ;
    };
    lResource_ID.setLabelFor(fResource_ID);
    fResource_ID.setBackground(AdempierePLAF.getInfoBackground());
    // Planner Lookup
    fPlanner_ID = new VLookup(MPPMRP.COLUMNNAME_Planner_ID, false, false, true, MLookupFactory.get(getCtx(), p_WindowNo, 0, MColumn.getColumn_ID(MPPProductPlanning.Table_Name, MPPMRP.COLUMNNAME_Planner_ID), DisplayType.Table)) {

        private static final long serialVersionUID = 1L;

        public void setValue(Object arg0) {
            super.setValue(arg0);
        }

        ;
    };
    lPlanner_ID.setLabelFor(fPlanner_ID);
    fPlanner_ID.setBackground(AdempierePLAF.getInfoBackground());
    // Wahrehouse Lookup
    fWarehouse_ID = new VLookup(MPPMRP.COLUMNNAME_M_Warehouse_ID, true, false, true, MLookupFactory.get(getCtx(), p_WindowNo, 0, MColumn.getColumn_ID(MWarehouse.Table_Name, MPPMRP.COLUMNNAME_M_Warehouse_ID), DisplayType.TableDir)) {

        private static final long serialVersionUID = 1L;

        public void setValue(Object arg0) {
            super.setValue(arg0);
        }

        ;
    };
    lWarehouse_ID.setLabelFor(fWarehouse_ID);
    fWarehouse_ID.setBackground(AdempierePLAF.getInfoBackground());
    fMaster.setSelected(false);
    fMaster.setReadWrite(false);
    fMRPReq.setSelected(false);
    fMRPReq.setReadWrite(false);
    fCreatePlan.setSelected(false);
    fCreatePlan.setReadWrite(false);
    lUOM.setText(Msg.translate(getCtx(), MUOM.COLUMNNAME_C_UOM_ID));
    fUOM.setBackground(AdempierePLAF.getInfoBackground());
    fUOM.setReadWrite(false);
    lType.setText(Msg.translate(getCtx(), MPPProductPlanning.COLUMNNAME_Order_Policy));
    fType.setBackground(AdempierePLAF.getInfoBackground());
    fType.setReadWrite(false);
    lOrderPeriod.setText(Msg.translate(getCtx(), MPPProductPlanning.COLUMNNAME_Order_Period));
    fOrderPeriod.setBackground(AdempierePLAF.getInfoBackground());
    fOrderPeriod.setReadWrite(false);
    lTimefence.setText(Msg.translate(getCtx(), MPPProductPlanning.COLUMNNAME_TimeFence));
    fTimefence.setBackground(AdempierePLAF.getInfoBackground());
    fTimefence.setReadWrite(false);
    lLeadtime.setText(Msg.translate(getCtx(), MPPProductPlanning.COLUMNNAME_DeliveryTime_Promised));
    fLeadtime.setBackground(AdempierePLAF.getInfoBackground());
    fLeadtime.setReadWrite(false);
    lMinOrd.setText(Msg.translate(getCtx(), MPPProductPlanning.COLUMNNAME_Order_Min));
    fMinOrd.setBackground(AdempierePLAF.getInfoBackground());
    fMinOrd.setReadWrite(false);
    lMaxOrd.setText(Msg.translate(getCtx(), MPPProductPlanning.COLUMNNAME_Order_Max));
    fMaxOrd.setBackground(AdempierePLAF.getInfoBackground());
    fMaxOrd.setReadWrite(false);
    lOrdMult.setText(Msg.translate(getCtx(), MPPProductPlanning.COLUMNNAME_Order_Pack));
    fOrdMult.setBackground(AdempierePLAF.getInfoBackground());
    fOrdMult.setReadWrite(false);
    lOrderQty.setText(Msg.translate(getCtx(), MPPProductPlanning.COLUMNNAME_Order_Qty));
    fOrderQty.setBackground(AdempierePLAF.getInfoBackground());
    fOrderQty.setReadWrite(false);
    lYield.setText(Msg.translate(getCtx(), MPPProductPlanning.COLUMNNAME_Yield));
    fYield.setBackground(AdempierePLAF.getInfoBackground());
    fYield.setReadWrite(false);
    lOnhand.setText(Msg.translate(getCtx(), MStorage.COLUMNNAME_QtyOnHand));
    fOnhand.setBackground(AdempierePLAF.getInfoBackground());
    fOnhand.setReadWrite(false);
    lSafetyStock.setText(Msg.translate(getCtx(), MPPProductPlanning.COLUMNNAME_SafetyStock));
    fSafetyStock.setBackground(AdempierePLAF.getInfoBackground());
    fSafetyStock.setReadWrite(false);
    lReserved.setText(Msg.translate(getCtx(), MStorage.COLUMNNAME_QtyReserved));
    fReserved.setBackground(AdempierePLAF.getInfoBackground());
    fReserved.setReadWrite(false);
    lAvailable.setText(Msg.translate(getCtx(), "QtyAvailable"));
    fAvailable.setBackground(AdempierePLAF.getInfoBackground());
    fAvailable.setReadWrite(false);
    lOrdered.setText(Msg.translate(getCtx(), MPPOrder.COLUMNNAME_QtyOrdered));
    fOrdered.setBackground(AdempierePLAF.getInfoBackground());
    fOrdered.setReadWrite(false);
    // Product Lookup
    fProduct_ID = new VLookup(MPPMRP.COLUMNNAME_M_Product_ID, true, false, true, MLookupFactory.get(getCtx(), p_WindowNo, 0, MColumn.getColumn_ID(MProduct.Table_Name, MPPMRP.COLUMNNAME_M_Product_ID), DisplayType.Search)) {

        private static final long serialVersionUID = 1L;

        public void setValue(Object arg0) {
            super.setValue(arg0);
            fAttrSetInstance_ID.setValue(new Integer(0));
        }

        ;
    };
    fAttrSetInstance_ID = new CButton() {

        private static final long serialVersionUID = 1L;

        private Object value;

        public Object getValue() {
            return value;
        }

        ;

        public void setText(String text) {
            if (text == null) {
                text = "---";
            }
            if (text.length() > 23) {
                text = text.substring(0, 20) + "...";
            }
            super.setText(text);
        }

        ;

        public void setValue(Object arg0) {
            value = arg0;
            int i = (arg0 instanceof Integer) ? ((Integer) arg0).intValue() : 0;
            if (i == 0) {
                setText(null);
            }
        }

        ;
    };
    fAttrSetInstance_ID.setValue(new Integer(0));
    fAttrSetInstance_ID.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            selectAttributeSetInstance();
        }
    });
    lProduct_ID.setLabelFor(fProduct_ID);
    fProduct_ID.setBackground(AdempierePLAF.getInfoBackground());
    //
    lDateFrom.setLabelFor(fDateFrom);
    fDateFrom.setBackground(AdempierePLAF.getInfoBackground());
    fDateFrom.setToolTipText(Msg.translate(getCtx(), MLot.COLUMNNAME_DateFrom));
    lDateTo.setLabelFor(fDateTo);
    fDateTo.setBackground(AdempierePLAF.getInfoBackground());
    fDateTo.setToolTipText(Msg.translate(getCtx(), MLot.COLUMNNAME_DateTo));
    fSupplyType = new VLookup(MPPMRP.COLUMNNAME_TypeMRP, false, false, true, MLookupFactory.get(getCtx(), p_WindowNo, 0, MColumn.getColumn_ID(MPPMRP.Table_Name, MPPMRP.COLUMNNAME_TypeMRP), DisplayType.List));
    lSupplyType.setLabelFor(fSupplyType);
    fSupplyType.setBackground(AdempierePLAF.getInfoBackground());
    //
    parameterPanel.setLayout(new ALayout());
    // 1st Row
    parameterPanel.add(lProduct_ID, new ALayoutConstraint(0, 0));
    parameterPanel.add(fProduct_ID, new ALayoutConstraint(0, 1));
    parameterPanel.add(lUOM, new ALayoutConstraint(0, 2));
    parameterPanel.add(fUOM, new ALayoutConstraint(0, 3));
    parameterPanel.add(lType, new ALayoutConstraint(0, 4));
    parameterPanel.add(fType, new ALayoutConstraint(0, 5));
    // 2nd Row
    parameterPanel.add(lAttrSetInstance_ID, new ALayoutConstraint(1, 0));
    parameterPanel.add(fAttrSetInstance_ID, new ALayoutConstraint(1, 1));
    parameterPanel.add(lOnhand, new ALayoutConstraint(1, 2));
    parameterPanel.add(fOnhand, new ALayoutConstraint(1, 3));
    parameterPanel.add(lOrderPeriod, new ALayoutConstraint(1, 4));
    parameterPanel.add(fOrderPeriod, new ALayoutConstraint(1, 5));
    // 3rd Row
    parameterPanel.add(lPlanner_ID, new ALayoutConstraint(2, 0));
    parameterPanel.add(fPlanner_ID, new ALayoutConstraint(2, 1));
    parameterPanel.add(lSafetyStock, new ALayoutConstraint(2, 2));
    parameterPanel.add(fSafetyStock, new ALayoutConstraint(2, 3));
    parameterPanel.add(lMinOrd, new ALayoutConstraint(2, 4));
    parameterPanel.add(fMinOrd, new ALayoutConstraint(2, 5));
    // 4th Row
    parameterPanel.add(lWarehouse_ID, new ALayoutConstraint(3, 0));
    parameterPanel.add(fWarehouse_ID, new ALayoutConstraint(3, 1));
    parameterPanel.add(lReserved, new ALayoutConstraint(3, 2));
    parameterPanel.add(fReserved, new ALayoutConstraint(3, 3));
    parameterPanel.add(lMaxOrd, new ALayoutConstraint(3, 4));
    parameterPanel.add(fMaxOrd, new ALayoutConstraint(3, 5));
    // 5th Row
    parameterPanel.add(lResource_ID, new ALayoutConstraint(4, 0));
    parameterPanel.add(fResource_ID, new ALayoutConstraint(4, 1));
    parameterPanel.add(lAvailable, new ALayoutConstraint(4, 2));
    parameterPanel.add(fAvailable, new ALayoutConstraint(4, 3));
    parameterPanel.add(lOrdMult, new ALayoutConstraint(4, 4));
    parameterPanel.add(fOrdMult, new ALayoutConstraint(4, 5));
    // 6th Row
    parameterPanel.add(lDateFrom, new ALayoutConstraint(5, 0));
    parameterPanel.add(fDateFrom, new ALayoutConstraint(5, 1));
    parameterPanel.add(lOrdered, new ALayoutConstraint(5, 2));
    parameterPanel.add(fOrdered, new ALayoutConstraint(5, 3));
    parameterPanel.add(lOrderQty, new ALayoutConstraint(5, 4));
    parameterPanel.add(fOrderQty, new ALayoutConstraint(5, 5));
    // 7th Row
    parameterPanel.add(lDateTo, new ALayoutConstraint(6, 0));
    parameterPanel.add(fDateTo, new ALayoutConstraint(6, 1));
    parameterPanel.add(lTimefence, new ALayoutConstraint(6, 4));
    parameterPanel.add(fTimefence, new ALayoutConstraint(6, 5));
    // 8th Row
    parameterPanel.add(fMaster, new ALayoutConstraint(7, 1));
    parameterPanel.add(fCreatePlan, new ALayoutConstraint(7, 3));
    parameterPanel.add(lLeadtime, new ALayoutConstraint(7, 4));
    parameterPanel.add(fLeadtime, new ALayoutConstraint(7, 5));
    // 9th Row
    parameterPanel.add(fMRPReq, new ALayoutConstraint(8, 3));
    parameterPanel.add(lYield, new ALayoutConstraint(8, 4));
    parameterPanel.add(fYield, new ALayoutConstraint(8, 5));
}
Also used : Language(org.compiere.util.Language) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) MLookup(org.compiere.model.MLookup) VLookup(org.compiere.grid.ed.VLookup) ALayoutConstraint(org.compiere.apps.ALayoutConstraint) CButton(org.compiere.swing.CButton) ALayout(org.compiere.apps.ALayout)

Aggregations

Language (org.compiere.util.Language)43 SQLException (java.sql.SQLException)11 PreparedStatement (java.sql.PreparedStatement)8 ResultSet (java.sql.ResultSet)8 Locale (java.util.Locale)8 MLookup (org.compiere.model.MLookup)7 Properties (java.util.Properties)6 PrintInfo (org.compiere.model.PrintInfo)6 MPrintFormat (org.compiere.print.MPrintFormat)5 IOException (java.io.IOException)4 Timestamp (java.sql.Timestamp)4 ArrayList (java.util.ArrayList)4 VLookup (org.compiere.grid.ed.VLookup)4 MQuery (org.compiere.model.MQuery)4 File (java.io.File)3 FileNotFoundException (java.io.FileNotFoundException)3 JRException (net.sf.jasperreports.engine.JRException)3 MUser (org.compiere.model.MUser)3 ReportEngine (org.compiere.print.ReportEngine)3 PrinterJob (java.awt.print.PrinterJob)2