use of org.adempiere.webui.component.ListModelTable in project adempiere by adempiere.
the class WCreateFromPanel method save.
/**
* Save Record
* @param trxName
* @return
*/
public boolean save(String trxName) {
ListModelTable model = dataTable.getModel();
int rows = model.getSize();
if (rows == 0)
return false;
return createFrom.save(dataTable, trxName);
}
use of org.adempiere.webui.component.ListModelTable in project adempiere by adempiere.
the class WCreateFromPanel method onEvent.
public void onEvent(Event e) throws Exception {
// OK - Save
if (e.getTarget().getId().equals(ConfirmPanel.A_OK)) {
try {
Trx.run(new TrxRunnable() {
public void run(String trxName) {
if (save(trxName)) {
createFrom.dispose();
}
}
});
} catch (Exception ex) {
FDialog.error(createFrom.getWindowNo(), this, "Error", ex.getLocalizedMessage());
}
} else // Cancel
if (e.getTarget().getId().equals(ConfirmPanel.A_CANCEL)) {
createFrom.dispose();
} else // Trifon
if (e.getTarget().getId().equals(SELECT_ALL)) {
ListModelTable model = dataTable.getModel();
int rows = model.getSize();
for (int i = 0; i < rows; i++) {
model.setValueAt(new Boolean(true), i, 0);
}
//refresh
dataTable.setModel(model);
info();
}
}
use of org.adempiere.webui.component.ListModelTable in project adempiere by adempiere.
the class WCreateFromPanel method info.
/**
* Update Info
*/
public void info() {
// If the method is not used then refresh
if (!createFrom.info()) {
ListModelTable model = dataTable.getModel();
int rows = model.getRowCount();
int count = 0;
for (int i = 0; i < rows; i++) {
if (((Boolean) model.getValueAt(i, 0)).booleanValue())
count++;
}
// Set Status Bar
setStatusLine(count, Msg.getMsg(Env.getCtx(), "Selected"));
}
}
use of org.adempiere.webui.component.ListModelTable in project adempiere by adempiere.
the class InvoiceHistory method initAtpTab.
// initUnconfirmedTab
/**
* Query ATP
*/
private void initAtpTab() {
// Done already
if (m_modelAtp != null)
return;
// Header
Vector<String> columnNames = new Vector<String>();
columnNames.add(Msg.translate(Env.getCtx(), "Date"));
columnNames.add(Msg.translate(Env.getCtx(), "QtyOnHand"));
columnNames.add(Msg.translate(Env.getCtx(), "C_BPartner_ID"));
columnNames.add(Msg.translate(Env.getCtx(), "QtyOrdered"));
columnNames.add(Msg.translate(Env.getCtx(), "QtyReserved"));
columnNames.add(Msg.translate(Env.getCtx(), "M_Locator_ID"));
columnNames.add(Msg.translate(Env.getCtx(), "M_AttributeSetInstance_ID"));
columnNames.add(Msg.translate(Env.getCtx(), "DocumentNo"));
columnNames.add(Msg.translate(Env.getCtx(), "M_Warehouse_ID"));
// Fill Storage Data
boolean showDetail = CLogMgt.isLevelFine();
String sql = "SELECT s.QtyOnHand, s.QtyReserved, s.QtyOrdered," + " productAttribute(s.M_AttributeSetInstance_ID), s.M_AttributeSetInstance_ID,";
if (!showDetail)
sql = "SELECT SUM(s.QtyOnHand), SUM(s.QtyReserved), SUM(s.QtyOrdered)," + " productAttribute(s.M_AttributeSetInstance_ID), 0,";
sql += " w.Name, l.Value " + "FROM M_Storage s" + " INNER JOIN M_Locator l ON (s.M_Locator_ID=l.M_Locator_ID)" + " INNER JOIN M_Warehouse w ON (l.M_Warehouse_ID=w.M_Warehouse_ID) " + "WHERE M_Product_ID=?";
if (m_M_Warehouse_ID != 0)
sql += " AND l.M_Warehouse_ID=?";
if (m_M_AttributeSetInstance_ID > 0)
sql += " AND s.M_AttributeSetInstance_ID=?";
sql += " AND (s.QtyOnHand<>0 OR s.QtyReserved<>0 OR s.QtyOrdered<>0)";
if (!showDetail)
sql += " GROUP BY productAttribute(s.M_AttributeSetInstance_ID), w.Name, l.Value";
sql += " ORDER BY l.Value";
Vector<Vector<Object>> data = new Vector<Vector<Object>>();
double qty = 0;
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, m_M_Product_ID);
if (m_M_Warehouse_ID != 0)
pstmt.setInt(2, m_M_Warehouse_ID);
if (m_M_AttributeSetInstance_ID > 0)
pstmt.setInt(3, m_M_AttributeSetInstance_ID);
rs = pstmt.executeQuery();
while (rs.next()) {
Vector<Object> line = new Vector<Object>(9);
// Date
line.add(null);
double qtyOnHand = rs.getDouble(1);
qty += qtyOnHand;
// Qty
line.add(new Double(qtyOnHand));
// BPartner
line.add(null);
// QtyOrdered
line.add(new Double(rs.getDouble(3)));
// QtyReserved
line.add(new Double(rs.getDouble(2)));
// Locator
line.add(rs.getString(7));
String asi = rs.getString(4);
if (showDetail && (asi == null || asi.length() == 0))
asi = "{" + rs.getInt(5) + "}";
// ASI
line.add(asi);
// DocumentNo
line.add(null);
// 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;
}
// Orders
sql = "SELECT o.DatePromised, ol.QtyReserved," + " productAttribute(ol.M_AttributeSetInstance_ID), ol.M_AttributeSetInstance_ID," + " dt.DocBaseType, bp.Name," + " dt.PrintName || ' ' || o.DocumentNo As DocumentNo, w.Name " + "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=?";
if (m_M_Warehouse_ID != 0)
sql += " AND ol.M_Warehouse_ID=?";
if (m_M_AttributeSetInstance_ID > 0)
sql += " AND ol.M_AttributeSetInstance_ID=?";
sql += " ORDER BY o.DatePromised";
try {
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, m_M_Product_ID);
if (m_M_Warehouse_ID != 0)
pstmt.setInt(2, m_M_Warehouse_ID);
if (m_M_AttributeSetInstance_ID > 0)
pstmt.setInt(3, m_M_AttributeSetInstance_ID);
rs = pstmt.executeQuery();
while (rs.next()) {
Vector<Object> line = new Vector<Object>(9);
// Date
line.add(rs.getTimestamp(1));
double oq = rs.getDouble(2);
String DocBaseType = rs.getString(5);
Double qtyReserved = null;
Double qtyOrdered = null;
if (MDocType.DOCBASETYPE_PurchaseOrder.equals(DocBaseType)) {
qtyOrdered = new Double(oq);
qty += oq;
} else {
qtyReserved = new Double(oq);
qty -= oq;
}
// Qty
line.add(new Double(qty));
// BPartner
line.add(rs.getString(6));
// QtyOrdered
line.add(qtyOrdered);
// QtyReserved
line.add(qtyReserved);
// Locator
line.add(null);
String asi = rs.getString(3);
if (showDetail && (asi == null || asi.length() == 0))
asi = "{" + rs.getInt(4) + "}";
// ASI
line.add(asi);
// DocumentNo
line.add(rs.getString(7));
// Warehouse
line.add(rs.getString(8));
data.add(line);
}
} catch (SQLException e) {
log.log(Level.SEVERE, sql, e);
} finally {
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
// Table
m_modelAtp = new ListModelTable(data);
m_tableAtp.setData(m_modelAtp, columnNames);
//
// Date
m_tableAtp.setColumnClass(0, Timestamp.class, true);
// Quantity
m_tableAtp.setColumnClass(1, Double.class, true);
// Partner
m_tableAtp.setColumnClass(2, String.class, true);
// Quantity
m_tableAtp.setColumnClass(3, Double.class, true);
// Quantity
m_tableAtp.setColumnClass(4, Double.class, true);
// Locator
m_tableAtp.setColumnClass(5, String.class, true);
// ASI
m_tableAtp.setColumnClass(6, String.class, true);
// DocNo
m_tableAtp.setColumnClass(7, String.class, true);
// Warehouse
m_tableAtp.setColumnClass(8, String.class, true);
//
m_tableAtp.autoSize();
}
use of org.adempiere.webui.component.ListModelTable in project adempiere by adempiere.
the class InvoiceHistory method dynInit.
// jbInit
/**
* Dynamic Init for Price Tab
*/
private boolean dynInit() {
// 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(), "QtyInvoiced"));
columnNames.add(Msg.translate(Env.getCtx(), "Discount"));
columnNames.add(Msg.translate(Env.getCtx(), "DocumentNo"));
columnNames.add(Msg.translate(Env.getCtx(), "DateInvoiced"));
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(true);
else
// Product of BPartner
data = queryProduct(true);
// Table
m_modelPrice = new ListModelTable(data);
m_tablePrice.setData(m_modelPrice, columnNames);
//
// Product/Partner
m_tablePrice.setColumnClass(0, String.class, true);
// Price
m_tablePrice.setColumnClass(1, Double.class, true);
// Quantity
m_tablePrice.setColumnClass(2, Double.class, true);
// Discount (%) to limit precision
m_tablePrice.setColumnClass(3, BigDecimal.class, true);
// DocNo
m_tablePrice.setColumnClass(4, String.class, true);
// Date
m_tablePrice.setColumnClass(5, Timestamp.class, true);
// Org
m_tablePrice.setColumnClass(6, String.class, true);
//
m_tablePrice.autoSize();
return data.size() != 0;
}
Aggregations