use of org.compiere.model.PO in project adempiere by adempiere.
the class POSOrderLinePanel method refreshPanel.
@Override
public void refreshPanel() {
// Remove Listener
posTable.getModel().removeTableModelListener(this);
// Set Editable Columns
orderLineTableHandle.setEditable(posPanel.isModifyPrice(), posPanel.isDrafted());
//
if (!posPanel.hasOrder())
posTable.loadTable(new PO[0]);
// Load Data
orderLineTableHandle.loadTable(posPanel.getC_Order_ID());
//
for (int i = 0; i < posTable.getRowCount(); i++) {
IDColumn key = (IDColumn) posTable.getModel().getValueAt(i, POSOrderLineTableHandle.POSITION_C_ORDERLINE_ID);
if (key != null && posPanel.getOrderLineId() > 0 && key.getRecord_ID() == posPanel.getOrderLineId()) {
posTable.getSelectionModel().setSelectionInterval(i, i);
showProductInfo(i);
break;
}
if (i == posTable.getRowCount() - 1) {
if (posPanel.hasLines()) {
posTable.getSelectionModel().setSelectionInterval(0, 0);
showProductInfo(0);
}
}
}
// Auto Size
posPanel.autoSize();
// Add Listener
posTable.getModel().addTableModelListener(this);
}
use of org.compiere.model.PO in project adempiere by adempiere.
the class ZoomMenuAction method getTableID.
private int getTableID(DefaultMutableTreeNode tn) throws Exception {
PO po = null;
if (tn.getUserObject() instanceof PO) {
po = (PO) tn.getUserObject();
} else if (tn.getUserObject() instanceof AbstractPOWrapper) {
po = ((AbstractPOWrapper) tn.getUserObject()).get();
} else {
return -1;
}
Field f = po.getClass().getField("Table_ID");
return f.getInt(null);
}
use of org.compiere.model.PO in project adempiere by adempiere.
the class WorkflowProcessor method sendEmail.
// sendAlerts
/**
* Send Alert EMail
* @param activity activity
* @param AD_Message message
* @param toProcess true if to process owner
* @param toSupervisor true if to Supervisor
* @return number of mails sent
*/
private int sendEmail(MWFActivity activity, String AD_Message, boolean toProcess, boolean toSupervisor) {
if (m_client == null || m_client.getAD_Client_ID() != activity.getAD_Client_ID())
m_client = MClient.get(getCtx(), activity.getAD_Client_ID());
MWFProcess process = new MWFProcess(getCtx(), activity.getAD_WF_Process_ID(), null);
String subjectVar = activity.getNode().getName();
String message = activity.getTextMsg();
if (message == null || message.length() == 0)
message = process.getTextMsg();
File pdf = null;
PO po = activity.getPO();
if (po instanceof DocAction) {
message = ((DocAction) po).getDocumentInfo() + "\n" + message;
pdf = ((DocAction) po).createPDF();
}
// Inactivity Alert: Workflow Activity {0}
String subject = Msg.getMsg(m_client.getAD_Language(), AD_Message, new Object[] { subjectVar });
// Prevent duplicates
ArrayList<Integer> list = new ArrayList<Integer>();
int counter = 0;
// To Activity Owner
if (m_client.sendEMail(activity.getAD_User_ID(), subject, message, pdf))
counter++;
list.add(new Integer(activity.getAD_User_ID()));
// To Process Owner
if (toProcess && process.getAD_User_ID() != activity.getAD_User_ID()) {
if (m_client.sendEMail(process.getAD_User_ID(), subject, message, pdf))
counter++;
list.add(new Integer(process.getAD_User_ID()));
}
// To Activity Responsible
MWFResponsible responsible = MWFResponsible.get(getCtx(), activity.getAD_WF_Responsible_ID());
counter += sendAlertToResponsible(responsible, list, process, subject, message, pdf);
// To Process Responsible
if (toProcess && process.getAD_WF_Responsible_ID() != activity.getAD_WF_Responsible_ID()) {
responsible = MWFResponsible.get(getCtx(), process.getAD_WF_Responsible_ID());
counter += sendAlertToResponsible(responsible, list, process, subject, message, pdf);
}
// Processor SuperVisor
if (toSupervisor && m_model.getSupervisor_ID() != 0 && !list.contains(new Integer(m_model.getSupervisor_ID()))) {
if (m_client.sendEMail(m_model.getSupervisor_ID(), subject, message, pdf))
counter++;
list.add(new Integer(m_model.getSupervisor_ID()));
}
return counter;
}
use of org.compiere.model.PO in project adempiere by adempiere.
the class TreeMaintenance method verifyTree.
// doIt
/**
* Verify Tree
* @param tree tree
*/
private String verifyTree(MTree tree) {
String nodeTableName = tree.getNodeTableName();
String sourceTableName = tree.getSourceTableName(true);
String sourceTableKey = sourceTableName + "_ID";
int AD_Client_ID = tree.getAD_Client_ID();
int C_Element_ID = 0;
if (MTree.TREETYPE_ElementValue.equals(tree.getTreeType())) {
String sql = "SELECT C_Element_ID FROM C_Element " + "WHERE AD_Tree_ID=" + tree.getAD_Tree_ID();
C_Element_ID = DB.getSQLValue(null, sql);
if (C_Element_ID <= 0)
throw new IllegalStateException("No Account Element found");
}
// Delete unused
StringBuffer sql = new StringBuffer();
sql.append("DELETE ").append(nodeTableName).append(" WHERE AD_Tree_ID=").append(tree.getAD_Tree_ID()).append(" AND Node_ID NOT IN (SELECT ").append(sourceTableKey).append(" FROM ").append(sourceTableName).append(" WHERE AD_Client_ID=").append(AD_Client_ID);
if (C_Element_ID > 0)
sql.append(" AND C_Element_ID=").append(C_Element_ID);
sql.append(")");
log.finer(sql.toString());
//
int deletes = DB.executeUpdate(sql.toString(), get_TrxName());
addLog(0, null, new BigDecimal(deletes), tree.getName() + " Deleted");
if (!tree.isAllNodes())
return tree.getName() + " OK";
// Insert new
int inserts = 0;
sql = new StringBuffer();
sql.append("SELECT ").append(sourceTableKey).append(" FROM ").append(sourceTableName).append(" WHERE AD_Client_ID=").append(AD_Client_ID);
if (C_Element_ID > 0)
sql.append(" AND C_Element_ID=").append(C_Element_ID);
sql.append(" AND ").append(sourceTableKey).append(" NOT IN (SELECT Node_ID FROM ").append(nodeTableName).append(" WHERE AD_Tree_ID=").append(tree.getAD_Tree_ID()).append(")");
log.finer(sql.toString());
//
boolean ok = true;
PreparedStatement pstmt = null;
try {
pstmt = DB.prepareStatement(sql.toString(), get_TrxName());
ResultSet rs = pstmt.executeQuery();
while (rs.next()) {
int Node_ID = rs.getInt(1);
PO node = null;
if (nodeTableName.equals("AD_TreeNode"))
node = new MTree_Node(tree, Node_ID);
else if (nodeTableName.equals("AD_TreeNodeBP"))
node = new MTree_NodeBP(tree, Node_ID);
else if (nodeTableName.equals("AD_TreeNodePR"))
node = new MTree_NodePR(tree, Node_ID);
else if (nodeTableName.equals("AD_TreeNodeMM"))
node = new MTree_NodeMM(tree, Node_ID);
//
if (node == null)
log.log(Level.SEVERE, "No Model for " + nodeTableName);
else {
if (node.save())
inserts++;
else
log.log(Level.SEVERE, "Could not add to " + tree + " Node_ID=" + Node_ID);
}
}
rs.close();
pstmt.close();
pstmt = null;
} catch (Exception e) {
log.log(Level.SEVERE, "verifyTree", e);
ok = false;
}
try {
if (pstmt != null)
pstmt.close();
pstmt = null;
} catch (Exception e) {
pstmt = null;
}
addLog(0, null, new BigDecimal(inserts), tree.getName() + " Inserted");
return tree.getName() + (ok ? " OK" : " Error");
}
use of org.compiere.model.PO in project adempiere by adempiere.
the class InventoryUtil method processDocument.
public static void processDocument(MMDocument doc, String docAction, String targetDocStatus) {
PO po = (PO) doc.document;
// po.saveEx();
po.load(po.get_TrxName());
po.set_ValueOfColumn("DocAction", docAction);
//
try {
if (!doc.document.processIt(docAction))
throw new AdempiereException(doc.document.getProcessMsg());
} catch (Exception e) {
throw (e instanceof AdempiereException ? (AdempiereException) e : new AdempiereException(e));
}
po.saveEx();
// Check DocSatus
if (targetDocStatus != null && !targetDocStatus.equals(doc.document.getDocStatus())) {
throw new AdempiereException("Doc process error " + doc + " (TargetDocStatus=" + targetDocStatus + ", DocStatus=" + doc.document.getDocStatus() + ")");
}
// Is Completed ?
if (DocAction.STATUS_Completed.equals(doc.document.getDocStatus())) {
// Track ASI:
if (!Util.isEmpty(doc.ASI)) {
}
}
}
Aggregations