Search in sources :

Example 21 with ListModelTable

use of org.adempiere.webui.component.ListModelTable in project adempiere by adempiere.

the class InvoiceHistory method initReservedOrderedTab.

/**
	 *	Query Reserved/Ordered
	 *	@param reserved po/so
	 */
private void initReservedOrderedTab(boolean reserved) {
    //	Done already
    if (reserved && m_modelReserved != null)
        return;
    if (!reserved && m_modelOrdered != null)
        return;
    //	Header
    Vector<String> columnNames = new Vector<String>();
    columnNames.add(Msg.translate(Env.getCtx(), m_C_BPartner_ID == 0 ? "C_BPartner_ID" : "M_Product_ID"));
    columnNames.add(Msg.translate(Env.getCtx(), "PriceActual"));
    columnNames.add(Msg.translate(Env.getCtx(), reserved ? "QtyReserved" : "QtyOrdered"));
    columnNames.add(Msg.translate(Env.getCtx(), "Discount"));
    columnNames.add(Msg.translate(Env.getCtx(), "DocumentNo"));
    columnNames.add(Msg.translate(Env.getCtx(), "DateOrdered"));
    columnNames.add(Msg.translate(Env.getCtx(), "M_Warehouse_ID"));
    //	Fill Data
    Vector<Vector<Object>> data = null;
    if (m_C_BPartner_ID == 0) {
        String sql = "SELECT bp.Name, ol.PriceActual,ol.PriceList,ol.QtyReserved," + "o.DateOrdered,dt.PrintName || ' ' || o.DocumentNo As DocumentNo, " + "w.Name," + // 8,9=M_PriceList_ID
        "ol.Discount, 0 " + "FROM C_Order o" + " INNER JOIN C_OrderLine ol ON (o.C_Order_ID=ol.C_Order_ID)" + " INNER JOIN C_DocType dt ON (o.C_DocType_ID=dt.C_DocType_ID)" + " INNER JOIN M_Warehouse w ON (ol.M_Warehouse_ID=w.M_Warehouse_ID)" + " INNER JOIN C_BPartner bp  ON (o.C_BPartner_ID=bp.C_BPartner_ID) " + "WHERE ol.QtyReserved<>0" + " AND ol.M_Product_ID=?" + " AND o.IsSOTrx=" + (reserved ? "'Y'" : "'N'") + " ORDER BY o.DateOrdered";
        //	Product By BPartner
        data = fillTable(sql, m_M_Product_ID);
    } else {
        String sql = "SELECT p.Name, ol.PriceActual,ol.PriceList,ol.QtyReserved," + "o.DateOrdered,dt.PrintName || ' ' || o.DocumentNo As DocumentNo, " + "w.Name," + // 8,9=M_PriceList_ID
        "ol.Discount, 0 " + "FROM C_Order o" + " INNER JOIN C_OrderLine ol ON (o.C_Order_ID=ol.C_Order_ID)" + " INNER JOIN C_DocType dt ON (o.C_DocType_ID=dt.C_DocType_ID)" + " INNER JOIN M_Warehouse w ON (ol.M_Warehouse_ID=w.M_Warehouse_ID)" + " INNER JOIN M_Product p  ON (ol.M_Product_ID=p.M_Product_ID) " + "WHERE ol.QtyReserved<>0" + " AND o.C_BPartner_ID=?" + " AND o.IsSOTrx=" + (reserved ? "'Y'" : "'N'") + " ORDER BY o.DateOrdered";
        //	Product of BP
        data = fillTable(sql, m_C_BPartner_ID);
    }
    //  Table
    if (reserved) {
        m_modelReserved = new ListModelTable(data);
        m_tableReserved.setData(m_modelReserved, columnNames);
        //
        //  Product/Partner
        m_tableReserved.setColumnClass(0, String.class, true);
        //  Price
        m_tableReserved.setColumnClass(1, BigDecimal.class, true);
        //  Quantity
        m_tableReserved.setColumnClass(2, Double.class, true);
        //  Discount (%)
        m_tableReserved.setColumnClass(3, BigDecimal.class, true);
        //  DocNo
        m_tableReserved.setColumnClass(4, String.class, true);
        //  Date
        m_tableReserved.setColumnClass(5, Timestamp.class, true);
        //  Warehouse
        m_tableReserved.setColumnClass(6, String.class, true);
        //
        m_tableReserved.autoSize();
    } else {
        m_modelOrdered = new ListModelTable(data);
        m_tableOrdered.setData(m_modelOrdered, columnNames);
        //
        //  Product/Partner
        m_tableOrdered.setColumnClass(0, String.class, true);
        //  Price
        m_tableOrdered.setColumnClass(1, BigDecimal.class, true);
        //  Quantity
        m_tableOrdered.setColumnClass(2, Double.class, true);
        //  Discount (%)
        m_tableOrdered.setColumnClass(3, BigDecimal.class, true);
        //  DocNo
        m_tableOrdered.setColumnClass(4, String.class, true);
        //  Date
        m_tableOrdered.setColumnClass(5, Timestamp.class, true);
        //  Warehouse
        m_tableOrdered.setColumnClass(6, String.class, true);
        //
        m_tableOrdered.autoSize();
    }
}
Also used : ListModelTable(org.adempiere.webui.component.ListModelTable) Vector(java.util.Vector)

Example 22 with ListModelTable

use of org.adempiere.webui.component.ListModelTable in project adempiere by adempiere.

the class WWFActivity method loadActivities.

/**
	 * 	Load Activities
	 * 	@return int
	 */
public int loadActivities() {
    long start = System.currentTimeMillis();
    int MAX_ACTIVITIES_IN_LIST = MSysConfig.getIntValue("MAX_ACTIVITIES_IN_LIST", 200, Env.getAD_Client_ID(Env.getCtx()));
    model = new ListModelTable();
    ArrayList<MWFActivity> list = new ArrayList<MWFActivity>();
    String sql = "SELECT * FROM AD_WF_Activity a " + "WHERE a.Processed='N' AND a.WFState='OS' AND (" + //	Owner of Activity
    " a.AD_User_ID=?" + //	Invoker (if no invoker = all)
    " OR EXISTS (SELECT * FROM AD_WF_Responsible r WHERE a.AD_WF_Responsible_ID=r.AD_WF_Responsible_ID" + //	#2
    " AND COALESCE(r.AD_User_ID,0)=0 AND COALESCE(r.AD_Role_ID,0)=0 AND (a.AD_User_ID=? OR a.AD_User_ID IS NULL))" + // Responsible User
    " OR EXISTS (SELECT * FROM AD_WF_Responsible r WHERE a.AD_WF_Responsible_ID=r.AD_WF_Responsible_ID" + //	#3
    " AND r.AD_User_ID=?)" + //	Responsible Role
    " OR EXISTS (SELECT * FROM AD_WF_Responsible r INNER JOIN AD_User_Roles ur ON (r.AD_Role_ID=ur.AD_Role_ID)" + //	#4
    " WHERE a.AD_WF_Responsible_ID=r.AD_WF_Responsible_ID AND ur.AD_User_ID=?)" + //
    ") ORDER BY a.Priority DESC, Created";
    int AD_User_ID = Env.getAD_User_ID(Env.getCtx());
    MRole role = MRole.get(Env.getCtx(), Env.getAD_Role_ID(Env.getCtx()));
    sql = role.addAccessSQL(sql, "a", true, false);
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    try {
        pstmt = DB.prepareStatement(sql, null);
        pstmt.setInt(1, AD_User_ID);
        pstmt.setInt(2, AD_User_ID);
        pstmt.setInt(3, AD_User_ID);
        pstmt.setInt(4, AD_User_ID);
        rs = pstmt.executeQuery();
        while (rs.next()) {
            MWFActivity activity = new MWFActivity(Env.getCtx(), rs, null);
            list.add(activity);
            List<Object> rowData = new ArrayList<Object>();
            rowData.add(activity.getPriority());
            rowData.add(activity.getNodeName());
            rowData.add(activity.getSummary());
            model.add(rowData);
            if (list.size() > MAX_ACTIVITIES_IN_LIST && MAX_ACTIVITIES_IN_LIST > 0) {
                log.warning("More then 200 Activities - ignored");
                break;
            }
        }
    } catch (Exception e) {
        log.log(Level.SEVERE, sql, e);
    } finally {
        DB.close(rs, pstmt);
        rs = null;
        pstmt = null;
    }
    m_activities = new MWFActivity[list.size()];
    list.toArray(m_activities);
    //
    log.fine("#" + m_activities.length + "(" + (System.currentTimeMillis() - start) + "ms)");
    m_index = 0;
    String[] columns = new String[] { Msg.translate(Env.getCtx(), "Priority"), Msg.translate(Env.getCtx(), "AD_WF_Node_ID"), Msg.translate(Env.getCtx(), "Summary") };
    WListItemRenderer renderer = new WListItemRenderer(Arrays.asList(columns));
    ListHeader header = new ListHeader();
    header.setWidth("30px");
    renderer.setListHeader(0, header);
    renderer.addTableValueChangeListener(listbox);
    model.setNoColumns(columns.length);
    listbox.setModel(model);
    listbox.setItemRenderer(renderer);
    listbox.repaint();
    listbox.setFixedLayout(true);
    return m_activities.length;
}
Also used : WListItemRenderer(org.adempiere.webui.component.WListItemRenderer) MRole(org.compiere.model.MRole) ArrayList(java.util.ArrayList) ListModelTable(org.adempiere.webui.component.ListModelTable) PreparedStatement(java.sql.PreparedStatement) MWFActivity(org.compiere.wf.MWFActivity) ResultSet(java.sql.ResultSet) ListHeader(org.adempiere.webui.component.ListHeader)

Example 23 with ListModelTable

use of org.adempiere.webui.component.ListModelTable in project adempiere by adempiere.

the class WAllocation method loadBPartner.

/**
	 *  Load Business Partner Info
	 *  - Payments
	 *  - Invoices
	 */
private void loadBPartner() {
    Clients.showBusy(null, true);
    //checkBPartner();
    Vector<Vector<Object>> data = getPaymentData(multiCurrency.isSelected(), dateField.getValue(), paymentTable);
    Vector<String> columnNames = getPaymentColumnNames(multiCurrency.isSelected());
    paymentTable.clear();
    //  Remove previous listeners
    paymentTable.getModel().removeTableModelListener(this);
    //  Set Model
    ListModelTable modelP = new ListModelTable(data);
    modelP.addTableModelListener(this);
    paymentTable.setData(modelP, columnNames);
    setPaymentColumnClass(paymentTable, multiCurrency.isSelected());
    paymentTable.recreateListHead();
    //
    data = getInvoiceData(multiCurrency.isSelected(), dateField.getValue(), invoiceTable);
    columnNames = getInvoiceColumnNames(multiCurrency.isSelected());
    invoiceTable.clear();
    //  Remove previous listeners
    invoiceTable.getModel().removeTableModelListener(this);
    //  Set Model
    ListModelTable modelI = new ListModelTable(data);
    modelI.addTableModelListener(this);
    invoiceTable.setData(modelI, columnNames);
    setInvoiceColumnClass(invoiceTable, multiCurrency.isSelected());
    invoiceTable.recreateListHead();
    //
    calculate(multiCurrency.isSelected());
    //  Calculate Totals
    calculate();
    Clients.showBusy(null, false);
}
Also used : ListModelTable(org.adempiere.webui.component.ListModelTable) Vector(java.util.Vector)

Example 24 with ListModelTable

use of org.adempiere.webui.component.ListModelTable in project adempiere by adempiere.

the class WCreateFromRMAUI method loadTableOIS.

/**
	 *  Load Order/Invoice/Shipment data into Table
	 *  @param data data
	 */
protected void loadTableOIS(Vector<?> data) {
    v_CreateFromPanel.getWListbox().clear();
    //  Remove previous listeners
    v_CreateFromPanel.getWListbox().getModel().removeTableModelListener(v_CreateFromPanel);
    //  Set Model
    ListModelTable model = new ListModelTable(data);
    model.addTableModelListener(v_CreateFromPanel);
    v_CreateFromPanel.getWListbox().setData(model, getOISColumnNames());
    //
    configureMiniTable(v_CreateFromPanel.getWListbox());
}
Also used : ListModelTable(org.adempiere.webui.component.ListModelTable)

Example 25 with ListModelTable

use of org.adempiere.webui.component.ListModelTable in project adempiere by adempiere.

the class WCreateFromInvoiceUI method loadTableOIS.

/**
	 *  Load Order/Invoice/Shipment data into Table
	 *  @param data data
	 */
protected void loadTableOIS(Vector<?> data) {
    v_CreateFromPanel.getWListbox().clear();
    //  Remove previous listeners
    v_CreateFromPanel.getWListbox().getModel().removeTableModelListener(v_CreateFromPanel);
    //  Set Model
    ListModelTable model = new ListModelTable(data);
    model.addTableModelListener(v_CreateFromPanel);
    v_CreateFromPanel.getWListbox().setData(model, getOISColumnNames());
    //
    configureMiniTable(v_CreateFromPanel.getWListbox());
}
Also used : ListModelTable(org.adempiere.webui.component.ListModelTable)

Aggregations

ListModelTable (org.adempiere.webui.component.ListModelTable)35 Vector (java.util.Vector)9 PreparedStatement (java.sql.PreparedStatement)4 ResultSet (java.sql.ResultSet)4 SQLException (java.sql.SQLException)3 ArrayList (java.util.ArrayList)3 BigDecimal (java.math.BigDecimal)2 WListItemRenderer (org.adempiere.webui.component.WListItemRenderer)2 IDColumn (org.compiere.minigrid.IDColumn)2 KeyNamePair (org.compiere.util.KeyNamePair)2 TrxRunnable (org.compiere.util.TrxRunnable)2 IOException (java.io.IOException)1 Timestamp (java.sql.Timestamp)1 List (java.util.List)1 Button (org.adempiere.webui.component.Button)1 Checkbox (org.adempiere.webui.component.Checkbox)1 Combobox (org.adempiere.webui.component.Combobox)1 ListHeader (org.adempiere.webui.component.ListHeader)1 Textbox (org.adempiere.webui.component.Textbox)1 MAcctSchema (org.compiere.model.MAcctSchema)1