Search in sources :

Example 31 with ListModelTable

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

the class InvoiceHistory method initUnconfirmedTab.

//	initReservedOrderedTab
/**
	 *	Query Unconfirmed
	 */
private void initUnconfirmedTab() {
    //	Done already
    if (m_modelUnconfirmed != 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(), "MovementQty"));
    columnNames.add(Msg.translate(Env.getCtx(), "MovementDate"));
    columnNames.add(Msg.translate(Env.getCtx(), "IsSOTrx"));
    columnNames.add(Msg.translate(Env.getCtx(), "DocumentNo"));
    columnNames.add(Msg.translate(Env.getCtx(), "M_Warehouse_ID"));
    //	Fill Data
    String sql = null;
    int parameter = 0;
    if (m_C_BPartner_ID == 0) {
        sql = "SELECT bp.Name," + " CASE WHEN io.IsSOTrx='Y' THEN iol.MovementQty*-1 ELSE iol.MovementQty END AS MovementQty," + " io.MovementDate,io.IsSOTrx," + " dt.PrintName || ' ' || io.DocumentNo As DocumentNo," + " w.Name " + "FROM M_InOutLine iol" + " INNER JOIN M_InOut io ON (iol.M_InOut_ID=io.M_InOut_ID)" + " INNER JOIN C_BPartner bp  ON (io.C_BPartner_ID=bp.C_BPartner_ID)" + " INNER JOIN C_DocType dt ON (io.C_DocType_ID=dt.C_DocType_ID)" + " INNER JOIN M_Warehouse w ON (io.M_Warehouse_ID=w.M_Warehouse_ID)" + " INNER JOIN M_InOutLineConfirm lc ON (iol.M_InOutLine_ID=lc.M_InOutLine_ID) " + "WHERE iol.M_Product_ID=?" + " AND lc.Processed='N' " + "ORDER BY io.MovementDate,io.IsSOTrx";
        parameter = m_M_Product_ID;
    } else {
        sql = "SELECT p.Name," + " CASE WHEN io.IsSOTrx='Y' THEN iol.MovementQty*-1 ELSE iol.MovementQty END AS MovementQty," + " io.MovementDate,io.IsSOTrx," + " dt.PrintName || ' ' || io.DocumentNo As DocumentNo," + " w.Name " + "FROM M_InOutLine iol" + " INNER JOIN M_InOut io ON (iol.M_InOut_ID=io.M_InOut_ID)" + " INNER JOIN M_Product p  ON (iol.M_Product_ID=p.M_Product_ID)" + " INNER JOIN C_DocType dt ON (io.C_DocType_ID=dt.C_DocType_ID)" + " INNER JOIN M_Warehouse w ON (io.M_Warehouse_ID=w.M_Warehouse_ID)" + " INNER JOIN M_InOutLineConfirm lc ON (iol.M_InOutLine_ID=lc.M_InOutLine_ID) " + "WHERE io.C_BPartner_ID=?" + " AND lc.Processed='N' " + "ORDER BY io.MovementDate,io.IsSOTrx";
        parameter = m_C_BPartner_ID;
    }
    Vector<Vector<Object>> data = new Vector<Vector<Object>>();
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    try {
        pstmt = DB.prepareStatement(sql, null);
        pstmt.setInt(1, parameter);
        rs = pstmt.executeQuery();
        while (rs.next()) {
            Vector<Object> line = new Vector<Object>(6);
            //	1-Name, 2-MovementQty, 3-MovementDate, 4-IsSOTrx, 5-DocumentNo
            //  Name
            line.add(rs.getString(1));
            //  Qty
            line.add(new Double(rs.getDouble(2)));
            //  Date
            line.add(rs.getTimestamp(3));
            //  IsSOTrx
            line.add(new Boolean("Y".equals(rs.getString(4))));
            //  DocNo
            line.add(rs.getString(5));
            //  Warehouse
            line.add(rs.getString(6));
            data.add(line);
        }
    } catch (SQLException e) {
        log.log(Level.SEVERE, sql, e);
    } finally {
        DB.close(rs, pstmt);
        rs = null;
        pstmt = null;
    }
    log.fine("#" + data.size());
    //  Table
    m_modelUnconfirmed = new ListModelTable(data);
    m_tableUnconfirmed.setData(m_modelUnconfirmed, columnNames);
    //
    //  Product/Partner
    m_tableUnconfirmed.setColumnClass(0, String.class, true);
    //  MovementQty
    m_tableUnconfirmed.setColumnClass(1, Double.class, true);
    //  MovementDate
    m_tableUnconfirmed.setColumnClass(2, Timestamp.class, true);
    //  IsSOTrx
    m_tableUnconfirmed.setColumnClass(3, Boolean.class, true);
    //  DocNo
    m_tableUnconfirmed.setColumnClass(4, String.class, true);
    //
    m_tableUnconfirmed.autoSize();
}
Also used : SQLException(java.sql.SQLException) ListModelTable(org.adempiere.webui.component.ListModelTable) PreparedStatement(java.sql.PreparedStatement) ResultSet(java.sql.ResultSet) Vector(java.util.Vector)

Example 32 with ListModelTable

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

the class InfoPanel method renderItems.

protected void renderItems() {
    if (m_count > 0) {
        if (m_count > PAGE_SIZE) {
            if (paging == null) {
                paging = new Paging();
                paging.setPageSize(PAGE_SIZE);
                paging.setTotalSize(m_count);
                paging.setDetailed(true);
                paging.addEventListener(ZulEvents.ON_PAGING, this);
                insertPagingComponent();
            } else {
                paging.setTotalSize(m_count);
                paging.setActivePage(0);
            }
            List<Object> subList = readLine(0, PAGE_SIZE);
            model = new ListModelTable(subList);
            model.setSorter(this);
            model.addTableModelListener(this);
            p_table.setData(model, null);
            pageNo = 0;
        } else {
            if (paging != null) {
                paging.setTotalSize(m_count);
                paging.setActivePage(0);
                pageNo = 0;
            }
            model = new ListModelTable(readLine(0, -1));
            model.setSorter(this);
            model.addTableModelListener(this);
            p_table.setData(model, null);
        }
    } else // metas c.ghita@metas.ro : start  
    {
        model = new ListModelTable();
        p_table.setData(model, null);
    }
    // metas c.ghita@metas.ro : start
    int no = m_count;
    setStatusLine(Integer.toString(no) + " " + Msg.getMsg(Env.getCtx(), "SearchRows_EnterQuery"), false);
    setStatusDB(Integer.toString(no));
    addDoubleClickListener();
}
Also used : Paging(org.zkoss.zul.Paging) ListModelTable(org.adempiere.webui.component.ListModelTable)

Example 33 with ListModelTable

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

the class InvoiceHistory method initOrderPriceHistoryTab.

//	initAtpTab
/**
	 * Query Order Price History [Sales/Purchase]
	 */
private void initOrderPriceHistoryTab() {
    // Done already
    if (m_modelOrderPrice != null)
        return;
    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(), "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(), "AD_Org_ID"));
    // Fill Data
    Vector<Vector<Object>> data = null;
    if (m_C_BPartner_ID == 0)
        // BPartner of Product
        data = queryBPartner(false);
    else
        // Product of BPartner
        data = queryProduct(false);
    // Table
    m_modelOrderPrice = new ListModelTable(data);
    m_tableOrderPrice.setData(m_modelOrderPrice, columnNames);
    //
    // Product/Partner
    m_tableOrderPrice.setColumnClass(0, String.class, true);
    // Price
    m_tableOrderPrice.setColumnClass(1, Double.class, true);
    // Quantity
    m_tableOrderPrice.setColumnClass(2, Double.class, true);
    //  Discount (%) to limit precision
    m_tableOrderPrice.setColumnClass(3, BigDecimal.class, true);
    // DocNo
    m_tableOrderPrice.setColumnClass(4, String.class, true);
    // Date
    m_tableOrderPrice.setColumnClass(5, Timestamp.class, true);
    // Org
    m_tableOrderPrice.setColumnClass(6, String.class, true);
    //
    m_tableOrderPrice.autoSize();
}
Also used : ListModelTable(org.adempiere.webui.component.ListModelTable) Vector(java.util.Vector)

Example 34 with ListModelTable

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

the class WScanBarUI method dynamicInitialise.

/**
     *  Initialises the dynamic components of the form.
     *  <li>Gets defaults for primary AcctSchema
     *  <li>Creates Table with Accounts
     */
private void dynamicInitialise() {
    ListModelTable model = new ListModelTable();
    productTable.setData(model, getColumnNames());
    setColumnClass(productTable);
    return;
}
Also used : ListModelTable(org.adempiere.webui.component.ListModelTable)

Example 35 with ListModelTable

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

the class WPOSOrderLinePanel method tableChanged.

@Override
public void tableChanged(WTableModelEvent event) {
    boolean isUpdate = (event.getType() == ListDataEvent.CONTENTS_CHANGED);
    int col = event.getColumn();
    int row = posTable.getSelectedRow();
    /*if(event.getColumn() == POSOrderLineTableHandle.POSITION_DELETE){
			posTable.getModel().removeTableModelListener(this);
			ListModelTable m_model = (ListModelTable)event.getModel();
			for(int x = 0; x < posTable.getRowCount(); x++){
				String value = m_model.getValueAt(x, 1).toString();
				if(value.length() == 0){
					IDColumn key = (IDColumn) m_model.getValueAt(x, 0);
					orderLineId = key.getRecord_ID();
					posPanel.deleteLine(orderLineId);
					posTable.getModel().remove(x);
				}
			}

			posTable.getModel().addTableModelListener(this);
			posPanel.refreshHeader();
			return;
		}*/
    if (!isUpdate || (col != POSOrderLineTableHandle.POSITION_QTYORDERED && col != POSOrderLineTableHandle.POSITION_PRICE)) {
        return;
    }
    if (event.getModel().equals(posTable.getModel())) {
        //Add Minitable Source Condition
        if (row != -1) {
            ListModelTable model = posTable.getModel();
            IDColumn key = (IDColumn) model.getValueAt(row, 0);
            posTable.getModel().removeTableModelListener(this);
            //	Validate Key
            if (key != null) {
                //	Set Current Order Line
                orderLineId = key.getRecord_ID();
                BigDecimal m_QtyOrdered = (BigDecimal) posTable.getValueAt(row, POSOrderLineTableHandle.POSITION_QTYORDERED);
                BigDecimal m_Price = (BigDecimal) posTable.getValueAt(row, POSOrderLineTableHandle.POSITION_PRICE);
                BigDecimal discountPercentage = (BigDecimal) posTable.getValueAt(row, POSOrderLineTableHandle.POSITION_DISCOUNT);
                posPanel.setQty(m_QtyOrdered);
                posPanel.setPrice(m_Price);
                posPanel.setDiscountPercentage(discountPercentage);
                updateLine();
            }
        }
    }
}
Also used : IDColumn(org.compiere.minigrid.IDColumn) ListModelTable(org.adempiere.webui.component.ListModelTable) BigDecimal(java.math.BigDecimal)

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