VOrderDistribution, VOrderReceiptIssue:

* organized imports
* fixed indentation
* added serialVersionUID = 1
This commit is contained in:
teo_sarca 2008-08-18 08:29:25 +00:00
parent 39d29a9116
commit ec6f0ea17c
1 changed files with 140 additions and 95 deletions

View File

@ -15,27 +15,70 @@
*****************************************************************************/ *****************************************************************************/
package org.eevolution.form; package org.eevolution.form;
import java.awt.*; import java.awt.BorderLayout;
import java.awt.event.*; import java.awt.Cursor;
import java.beans.*; import java.awt.FlowLayout;
import java.math.*; import java.awt.event.ActionEvent;
import java.sql.*; import java.awt.event.ActionListener;
import java.util.*; import java.beans.PropertyChangeEvent;
import java.util.logging.*; import java.beans.VetoableChangeListener;
import javax.swing.*; import java.math.BigDecimal;
import javax.swing.event.*; import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.logging.Level;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;
import org.adempiere.plaf.AdempierePLAF; import org.adempiere.plaf.AdempierePLAF;
import org.compiere.apps.*; import org.compiere.apps.ADialog;
import org.compiere.apps.form.*; import org.compiere.apps.ADialogDialog;
import org.compiere.grid.ed.*; import org.compiere.apps.ConfirmPanel;
import org.compiere.minigrid.*; import org.compiere.apps.ProcessCtl;
import org.compiere.model.*; import org.compiere.apps.StatusBar;
import org.compiere.plaf.*; import org.compiere.apps.form.FormFrame;
import org.compiere.print.*; import org.compiere.apps.form.FormPanel;
import org.compiere.process.*; import org.compiere.grid.ed.VComboBox;
import org.compiere.swing.*; import org.compiere.grid.ed.VLookup;
import org.compiere.util.*; import org.compiere.minigrid.IDColumn;
import org.compiere.minigrid.MiniTable;
import org.compiere.model.MColumn;
import org.compiere.model.MLocator;
import org.compiere.model.MLookup;
import org.compiere.model.MLookupFactory;
import org.compiere.model.MMovement;
import org.compiere.model.MOrder;
import org.compiere.model.MPInstance;
import org.compiere.model.MPInstancePara;
import org.compiere.model.MPrivateAccess;
import org.compiere.model.MProcess;
import org.compiere.model.MQuery;
import org.compiere.model.PrintInfo;
import org.compiere.plaf.CompiereColor;
import org.compiere.print.MPrintFormat;
import org.compiere.print.ReportEngine;
import org.compiere.print.Viewer;
import org.compiere.process.ProcessInfo;
import org.compiere.process.ProcessInfoUtil;
import org.compiere.swing.CLabel;
import org.compiere.swing.CPanel;
import org.compiere.swing.CTabbedPane;
import org.compiere.swing.CTextPane;
import org.compiere.util.ASyncProcess;
import org.compiere.util.CLogger;
import org.compiere.util.DB;
import org.compiere.util.DisplayType;
import org.compiere.util.Env;
import org.compiere.util.KeyNamePair;
import org.compiere.util.Msg;
import org.compiere.util.Trx;
import org.eevolution.model.MDDOrder; import org.eevolution.model.MDDOrder;
/** /**
@ -46,8 +89,10 @@ import org.eevolution.model.MDDOrder;
*/ */
public class VOrderDistribution extends CPanel public class VOrderDistribution extends CPanel
implements FormPanel, ActionListener, VetoableChangeListener, implements FormPanel, ActionListener, VetoableChangeListener,
ChangeListener, TableModelListener, ASyncProcess ChangeListener, TableModelListener, ASyncProcess
{ {
private static final long serialVersionUID = 1L;
/** /**
* Initialize Panel * Initialize Panel
* @param WindowNo window * @param WindowNo window
@ -245,40 +290,40 @@ public class VOrderDistribution extends CPanel
*/ */
private String getOrderSQL() private String getOrderSQL()
{ {
// Create SQL // Create SQL
StringBuffer sql = new StringBuffer( StringBuffer sql = new StringBuffer(
"SELECT DD_Order_ID, o.Name, dt.Name, DocumentNo, bp.Name, DateOrdered " "SELECT DD_Order_ID, o.Name, dt.Name, DocumentNo, bp.Name, DateOrdered "
+ "FROM M_Movement_Candidate_v ic, AD_Org o, C_BPartner bp, C_DocType dt " + "FROM M_Movement_Candidate_v ic, AD_Org o, C_BPartner bp, C_DocType dt "
+ "WHERE ic.AD_Org_ID=o.AD_Org_ID" + "WHERE ic.AD_Org_ID=o.AD_Org_ID"
+ " AND ic.C_BPartner_ID=bp.C_BPartner_ID" + " AND ic.C_BPartner_ID=bp.C_BPartner_ID"
+ " AND ic.C_DocType_ID=dt.C_DocType_ID" + " AND ic.C_DocType_ID=dt.C_DocType_ID"
+ " AND ic.AD_Client_ID=?"); + " AND ic.AD_Client_ID=?");
if(m_M_Locator_ID != null) if(m_M_Locator_ID != null)
sql.append(" AND ic.M_Locator_ID=").append(m_M_Locator_ID); sql.append(" AND ic.M_Locator_ID=").append(m_M_Locator_ID);
/*if (m_M_Warehouse_ID != null) /*if (m_M_Warehouse_ID != null)
sql.append(" AND ic.M_Warehouse_ID=").append(m_M_Warehouse_ID);*/ sql.append(" AND ic.M_Warehouse_ID=").append(m_M_Warehouse_ID);*/
if(m_M_LocatorTo_ID != null) if(m_M_LocatorTo_ID != null)
sql.append(" AND ic.M_LocatorTo_ID=").append(m_M_LocatorTo_ID); sql.append(" AND ic.M_LocatorTo_ID=").append(m_M_LocatorTo_ID);
if (m_C_BPartner_ID != null) if (m_C_BPartner_ID != null)
sql.append(" AND ic.C_BPartner_ID=").append(m_C_BPartner_ID); sql.append(" AND ic.C_BPartner_ID=").append(m_C_BPartner_ID);
// bug - [ 1713317 ] Generate Shipments (manual) show locked records // bug - [ 1713317 ] Generate Shipments (manual) show locked records
/* begin - Exclude locked records; @Trifon */ /* begin - Exclude locked records; @Trifon */
int AD_User_ID = Env.getContextAsInt(Env.getCtx(), "#AD_User_ID"); int AD_User_ID = Env.getContextAsInt(Env.getCtx(), "#AD_User_ID");
String lockedIDs = MPrivateAccess.getLockedRecordWhere(MOrder.Table_ID, AD_User_ID); String lockedIDs = MPrivateAccess.getLockedRecordWhere(MOrder.Table_ID, AD_User_ID);
if (lockedIDs != null) if (lockedIDs != null)
{ {
if (sql.length() > 0) if (sql.length() > 0)
sql.append(" AND "); sql.append(" AND ");
sql.append("DD_Order_ID").append(lockedIDs); sql.append("DD_Order_ID").append(lockedIDs);
} }
/* eng - Exclude locked records; @Trifon */ /* eng - Exclude locked records; @Trifon */
// //
sql.append(" ORDER BY o.Name,bp.Name,DateOrdered"); sql.append(" ORDER BY o.Name,bp.Name,DateOrdered");
return sql.toString(); return sql.toString();
} }
/** /**
@ -293,7 +338,7 @@ public class VOrderDistribution extends CPanel
KeyNamePair docTypeKNPair = (KeyNamePair)cmbDocType.getSelectedItem(); KeyNamePair docTypeKNPair = (KeyNamePair)cmbDocType.getSelectedItem();
sql = getOrderSQL(); sql = getOrderSQL();
log.fine(sql); log.fine(sql);
// reset table // reset table
@ -330,7 +375,7 @@ public class VOrderDistribution extends CPanel
} }
// //
miniTable.autoSize(); miniTable.autoSize();
// statusBar.setStatusDB(String.valueOf(miniTable.getRowCount())); // statusBar.setStatusDB(String.valueOf(miniTable.getRowCount()));
} // executeQuery } // executeQuery
/** /**
@ -358,15 +403,15 @@ public class VOrderDistribution extends CPanel
} }
if (cmbDocType.equals(e.getSource())) if (cmbDocType.equals(e.getSource()))
{ {
executeQuery(); executeQuery();
return; return;
} }
// //
saveSelection(); saveSelection();
if (selection != null if (selection != null
&& selection.size() > 0 && selection.size() > 0
&& m_selectionActive // on selection tab && m_selectionActive // on selection tab
&& m_M_Locator_ID != null) && m_M_Locator_ID != null)
generateMovements (); generateMovements ();
else else
dispose(); dispose();
@ -380,7 +425,7 @@ public class VOrderDistribution extends CPanel
{ {
log.info(e.getPropertyName() + "=" + e.getNewValue()); log.info(e.getPropertyName() + "=" + e.getNewValue());
//if (e.getPropertyName().equals("M_Warehouse_ID")) //if (e.getPropertyName().equals("M_Warehouse_ID"))
//m_M_Warehouse_ID = e.getNewValue(); //m_M_Warehouse_ID = e.getNewValue();
if (e.getPropertyName().equals("M_Locator_ID")) if (e.getPropertyName().equals("M_Locator_ID"))
m_M_Locator_ID = e.getNewValue(); m_M_Locator_ID = e.getNewValue();
if (e.getPropertyName().equals("M_LocatorTo_ID")) if (e.getPropertyName().equals("M_LocatorTo_ID"))
@ -439,7 +484,7 @@ public class VOrderDistribution extends CPanel
for (int i = 0; i < rows; i++) for (int i = 0; i < rows; i++)
{ {
IDColumn id = (IDColumn)miniTable.getValueAt(i, 0); // ID in column 0 IDColumn id = (IDColumn)miniTable.getValueAt(i, 0); // ID in column 0
// log.fine( "Row=" + i + " - " + id); // log.fine( "Row=" + i + " - " + id);
if (id != null && id.isSelected()) if (id != null && id.isSelected())
results.add(id.getRecord_ID()); results.add(id.getRecord_ID());
} }
@ -566,11 +611,11 @@ public class VOrderDistribution extends CPanel
ProcessInfoUtil.setLogFromDB(pi); ProcessInfoUtil.setLogFromDB(pi);
StringBuffer iText = new StringBuffer(); StringBuffer iText = new StringBuffer();
iText.append("<b>").append(pi.getSummary()) iText.append("<b>").append(pi.getSummary())
.append("</b><br>(") .append("</b><br>(")
.append(Msg.getMsg(Env.getCtx(), "InOutGenerateInfo")) .append(Msg.getMsg(Env.getCtx(), "InOutGenerateInfo"))
// Shipments are generated depending on the Delivery Rule selection in the Order // Shipments are generated depending on the Delivery Rule selection in the Order
.append(")<br>") .append(")<br>")
.append(pi.getLogInfo(true)); .append(pi.getLogInfo(true));
info.setText(iText.toString()); info.setText(iText.toString());
// Reset Selection // Reset Selection
@ -589,7 +634,7 @@ public class VOrderDistribution extends CPanel
// OK to print shipments // OK to print shipments
if (ADialog.ask(m_WindowNo, this, "PrintShipments")) if (ADialog.ask(m_WindowNo, this, "PrintShipments"))
{ {
// info.append("\n\n" + Msg.getMsg(Env.getCtx(), "PrintShipments")); // info.append("\n\n" + Msg.getMsg(Env.getCtx(), "PrintShipments"));
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
int retValue = ADialogDialog.A_CANCEL; // see also ProcessDialog.printShipments/Invoices int retValue = ADialogDialog.A_CANCEL; // see also ProcessDialog.printShipments/Invoices
do do
@ -598,20 +643,20 @@ public class VOrderDistribution extends CPanel
for (int i = 0; i < ids.length; i++) for (int i = 0; i < ids.length; i++)
{ {
int M_Movement_ID = ids[i]; int M_Movement_ID = ids[i];
MPrintFormat format = MPrintFormat.get(Env.getCtx(), MPrintFormat.getPrintFormat_ID("Inventory Move Hdr (Example)", MMovement.Table_ID, 0), false); MPrintFormat format = MPrintFormat.get(Env.getCtx(), MPrintFormat.getPrintFormat_ID("Inventory Move Hdr (Example)", MMovement.Table_ID, 0), false);
MQuery query = new MQuery(MMovement.Table_Name); MQuery query = new MQuery(MMovement.Table_Name);
query.addRestriction(MMovement.COLUMNNAME_M_Movement_ID, MQuery.EQUAL, M_Movement_ID); query.addRestriction(MMovement.COLUMNNAME_M_Movement_ID, MQuery.EQUAL, M_Movement_ID);
// Engine // Engine
PrintInfo info = new PrintInfo(MMovement.Table_Name,MMovement.Table_ID, M_Movement_ID); PrintInfo info = new PrintInfo(MMovement.Table_Name,MMovement.Table_ID, M_Movement_ID);
ReportEngine re = new ReportEngine(Env.getCtx(), format, query, info); ReportEngine re = new ReportEngine(Env.getCtx(), format, query, info);
re.print(); re.print();
new Viewer(re); new Viewer(re);
} }
ADialogDialog d = new ADialogDialog (m_frame, ADialogDialog d = new ADialogDialog (m_frame,
Env.getHeader(Env.getCtx(), m_WindowNo), Env.getHeader(Env.getCtx(), m_WindowNo),
Msg.getMsg(Env.getCtx(), "PrintoutOK?"), Msg.getMsg(Env.getCtx(), "PrintoutOK?"),
JOptionPane.QUESTION_MESSAGE); JOptionPane.QUESTION_MESSAGE);
retValue = d.getReturnCode(); retValue = d.getReturnCode();
} }
while (retValue == ADialogDialog.A_CANCEL); while (retValue == ADialogDialog.A_CANCEL);