Refactor custom form - ID: 2787613
This commit is contained in:
parent
17253beea8
commit
7e277819ca
File diff suppressed because it is too large
Load Diff
|
@ -114,7 +114,6 @@ public abstract class VCreateFrom extends CDialog
|
||||||
{
|
{
|
||||||
// Register defaults:
|
// Register defaults:
|
||||||
s_registeredClasses = new HashMap<Integer, Class<? extends VCreateFrom>>();
|
s_registeredClasses = new HashMap<Integer, Class<? extends VCreateFrom>>();
|
||||||
s_registeredClasses.put(I_M_InOut.Table_ID, VCreateFromShipment.class);
|
|
||||||
//s_registeredClasses.put(I_C_PaySelection.Table_ID, null); // ignore - will call process C_PaySelection_CreateFrom
|
//s_registeredClasses.put(I_C_PaySelection.Table_ID, null); // ignore - will call process C_PaySelection_CreateFrom
|
||||||
s_registeredClasses.put(I_M_RMA.Table_ID, VCreateFromRMA.class);
|
s_registeredClasses.put(I_M_RMA.Table_ID, VCreateFromRMA.class);
|
||||||
}
|
}
|
||||||
|
@ -394,13 +393,13 @@ public abstract class VCreateFrom extends CDialog
|
||||||
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0));
|
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0));
|
||||||
parameterStdPanel.add(sameWarehouseCb, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0
|
parameterStdPanel.add(sameWarehouseCb, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0
|
||||||
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0));
|
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0));
|
||||||
if (this instanceof VCreateFromShipment) {
|
/* if (this instanceof VCreateFromShipment) {
|
||||||
parameterStdPanel.add(upcLabel, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0
|
parameterStdPanel.add(upcLabel, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0
|
||||||
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
|
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
|
||||||
parameterStdPanel.add(upcField, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0
|
parameterStdPanel.add(upcField, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0
|
||||||
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0));
|
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0));
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
// Add RMA document selection to panel
|
// Add RMA document selection to panel
|
||||||
parameterStdPanel.add(rmaLabel, new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0
|
parameterStdPanel.add(rmaLabel, new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class VCreateFromFactory
|
||||||
s_registeredClasses.put(I_C_Invoice.Table_ID, VCreateFromInvoiceUI.class);
|
s_registeredClasses.put(I_C_Invoice.Table_ID, VCreateFromInvoiceUI.class);
|
||||||
|
|
||||||
s_registeredClasses.put(I_C_BankStatement.Table_ID, VCreateFromStatementUI.class);
|
s_registeredClasses.put(I_C_BankStatement.Table_ID, VCreateFromStatementUI.class);
|
||||||
s_registeredClasses.put(I_M_InOut.Table_ID, VCreateFromShipment.class);
|
s_registeredClasses.put(I_M_InOut.Table_ID, VCreateFromShipmentUI.class);
|
||||||
s_registeredClasses.put(I_M_RMA.Table_ID, VCreateFromRMA.class);
|
s_registeredClasses.put(I_M_RMA.Table_ID, VCreateFromRMA.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,482 @@
|
||||||
|
/******************************************************************************
|
||||||
|
* Copyright (C) 2009 Low Heng Sin *
|
||||||
|
* Copyright (C) 2009 Idalica Corporation *
|
||||||
|
* This program is free software; you can redistribute it and/or modify it *
|
||||||
|
* under the terms version 2 of the GNU General Public License as published *
|
||||||
|
* by the Free Software Foundation. This program is distributed in the hope *
|
||||||
|
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||||
|
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||||
|
* See the GNU General Public License for more details. *
|
||||||
|
* You should have received a copy of the GNU General Public License along *
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
package org.compiere.grid;
|
||||||
|
|
||||||
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.GridBagConstraints;
|
||||||
|
import java.awt.GridBagLayout;
|
||||||
|
import java.awt.Insets;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.beans.PropertyChangeEvent;
|
||||||
|
import java.beans.VetoableChangeListener;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Vector;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
import javax.swing.JCheckBox;
|
||||||
|
import javax.swing.JComboBox;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JTextField;
|
||||||
|
import javax.swing.table.DefaultTableModel;
|
||||||
|
|
||||||
|
import org.compiere.apps.AEnv;
|
||||||
|
import org.compiere.grid.ed.VLocator;
|
||||||
|
import org.compiere.grid.ed.VLookup;
|
||||||
|
import org.compiere.minigrid.IMiniTable;
|
||||||
|
import org.compiere.model.GridTab;
|
||||||
|
import org.compiere.model.MDocType;
|
||||||
|
import org.compiere.model.MLocator;
|
||||||
|
import org.compiere.model.MLocatorLookup;
|
||||||
|
import org.compiere.model.MLookup;
|
||||||
|
import org.compiere.model.MLookupFactory;
|
||||||
|
import org.compiere.model.MProduct;
|
||||||
|
import org.compiere.swing.CPanel;
|
||||||
|
import org.compiere.util.CLogger;
|
||||||
|
import org.compiere.util.DisplayType;
|
||||||
|
import org.compiere.util.Env;
|
||||||
|
import org.compiere.util.KeyNamePair;
|
||||||
|
import org.compiere.util.Msg;
|
||||||
|
|
||||||
|
public class VCreateFromShipmentUI extends CreateFromShipment implements ActionListener, VetoableChangeListener
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private VCreateFromDialog dialog;
|
||||||
|
|
||||||
|
public VCreateFromShipmentUI(GridTab mTab)
|
||||||
|
{
|
||||||
|
super(mTab);
|
||||||
|
log.info(getGridTab().toString());
|
||||||
|
|
||||||
|
dialog = new VCreateFromDialog(this, getGridTab().getWindowNo(), true);
|
||||||
|
|
||||||
|
p_WindowNo = getGridTab().getWindowNo();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!dynInit())
|
||||||
|
return;
|
||||||
|
jbInit();
|
||||||
|
|
||||||
|
setInitOK(true);
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
log.log(Level.SEVERE, "", e);
|
||||||
|
setInitOK(false);
|
||||||
|
}
|
||||||
|
AEnv.positionCenterWindow(Env.getWindow(p_WindowNo), dialog);
|
||||||
|
} // VCreateFrom
|
||||||
|
|
||||||
|
/** Window No */
|
||||||
|
private int p_WindowNo;
|
||||||
|
|
||||||
|
/** Logger */
|
||||||
|
private CLogger log = CLogger.getCLogger(getClass());
|
||||||
|
|
||||||
|
//
|
||||||
|
private JLabel bPartnerLabel = new JLabel();
|
||||||
|
private VLookup bPartnerField;
|
||||||
|
|
||||||
|
private JLabel orderLabel = new JLabel();
|
||||||
|
private JComboBox orderField = new JComboBox();
|
||||||
|
|
||||||
|
private JLabel invoiceLabel = new JLabel();
|
||||||
|
private JComboBox invoiceField = new JComboBox();
|
||||||
|
|
||||||
|
/** Label for the rma selection */
|
||||||
|
private JLabel rmaLabel = new JLabel();
|
||||||
|
/** Combo box for selecting RMA document */
|
||||||
|
private JComboBox rmaField = new JComboBox();
|
||||||
|
|
||||||
|
private JLabel upcLabel = new JLabel();
|
||||||
|
private JTextField upcField = new JTextField();
|
||||||
|
|
||||||
|
private JCheckBox sameWarehouseCb = new JCheckBox();
|
||||||
|
private JLabel locatorLabel = new JLabel();
|
||||||
|
private VLocator locatorField = new VLocator();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dynamic Init
|
||||||
|
* @throws Exception if Lookups cannot be initialized
|
||||||
|
* @return true if initialized
|
||||||
|
*/
|
||||||
|
public boolean dynInit() throws Exception
|
||||||
|
{
|
||||||
|
log.config("");
|
||||||
|
|
||||||
|
super.dynInit();
|
||||||
|
|
||||||
|
dialog.setTitle(getTitle());
|
||||||
|
|
||||||
|
// load Locator
|
||||||
|
MLocatorLookup locator = new MLocatorLookup(Env.getCtx(), p_WindowNo);
|
||||||
|
locatorField = new VLocator ("M_Locator_ID", true, false, true, locator, p_WindowNo);
|
||||||
|
sameWarehouseCb.setSelected(true);
|
||||||
|
sameWarehouseCb.addActionListener(this);
|
||||||
|
|
||||||
|
initBPartner(false);
|
||||||
|
bPartnerField.addVetoableChangeListener(this);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} // dynInit
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Static Init.
|
||||||
|
* <pre>
|
||||||
|
* parameterPanel
|
||||||
|
* parameterBankPanel
|
||||||
|
* parameterStdPanel
|
||||||
|
* bPartner/order/invoice/shopment/licator Label/Field
|
||||||
|
* dataPane
|
||||||
|
* southPanel
|
||||||
|
* confirmPanel
|
||||||
|
* statusBar
|
||||||
|
* </pre>
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
private void jbInit() throws Exception
|
||||||
|
{
|
||||||
|
bPartnerLabel.setText(Msg.getElement(Env.getCtx(), "C_BPartner_ID"));
|
||||||
|
orderLabel.setText(Msg.getElement(Env.getCtx(), "C_Order_ID", false));
|
||||||
|
locatorLabel.setText(Msg.translate(Env.getCtx(), "M_Locator_ID"));
|
||||||
|
invoiceLabel.setText(Msg.getElement(Env.getCtx(), "C_Invoice_ID", false));
|
||||||
|
sameWarehouseCb.setText(Msg.getMsg(Env.getCtx(), "FromSameWarehouseOnly", true));
|
||||||
|
sameWarehouseCb.setToolTipText(Msg.getMsg(Env.getCtx(), "FromSameWarehouseOnly", false));
|
||||||
|
rmaLabel.setText(Msg.translate(Env.getCtx(), "M_RMA_ID"));
|
||||||
|
upcLabel.setText(Msg.getElement(Env.getCtx(), "UPC", false));
|
||||||
|
|
||||||
|
CPanel parameterPanel = dialog.getParameterPanel();
|
||||||
|
parameterPanel.setLayout(new BorderLayout());
|
||||||
|
CPanel parameterStdPanel = new CPanel(new GridBagLayout());
|
||||||
|
parameterPanel.add(parameterStdPanel, BorderLayout.CENTER);
|
||||||
|
|
||||||
|
parameterStdPanel.add(bPartnerLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
|
||||||
|
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
|
||||||
|
if (bPartnerField != null)
|
||||||
|
parameterStdPanel.add(bPartnerField, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0
|
||||||
|
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0));
|
||||||
|
|
||||||
|
parameterStdPanel.add(orderLabel, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0
|
||||||
|
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
|
||||||
|
parameterStdPanel.add(orderField, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0
|
||||||
|
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0));
|
||||||
|
|
||||||
|
parameterStdPanel.add(invoiceLabel, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0
|
||||||
|
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
|
||||||
|
parameterStdPanel.add(invoiceField, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0
|
||||||
|
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0));
|
||||||
|
|
||||||
|
parameterStdPanel.add(locatorLabel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0
|
||||||
|
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
|
||||||
|
parameterStdPanel.add(locatorField, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0
|
||||||
|
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0));
|
||||||
|
parameterStdPanel.add(sameWarehouseCb, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0
|
||||||
|
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0));
|
||||||
|
parameterStdPanel.add(upcLabel, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0
|
||||||
|
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
|
||||||
|
parameterStdPanel.add(upcField, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0
|
||||||
|
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0));
|
||||||
|
|
||||||
|
// Add RMA document selection to panel
|
||||||
|
parameterStdPanel.add(rmaLabel, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0
|
||||||
|
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
|
||||||
|
parameterStdPanel.add(rmaField, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0
|
||||||
|
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0));
|
||||||
|
} // jbInit
|
||||||
|
|
||||||
|
/*************************************************************************/
|
||||||
|
|
||||||
|
private boolean m_actionActive = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action Listener
|
||||||
|
* @param e event
|
||||||
|
*/
|
||||||
|
public void actionPerformed(ActionEvent e)
|
||||||
|
{
|
||||||
|
log.config("Action=" + e.getActionCommand());
|
||||||
|
|
||||||
|
if (m_actionActive)
|
||||||
|
return;
|
||||||
|
m_actionActive = true;
|
||||||
|
log.config("Action=" + e.getActionCommand());
|
||||||
|
// Order
|
||||||
|
if (e.getSource().equals(orderField))
|
||||||
|
{
|
||||||
|
KeyNamePair pp = (KeyNamePair)orderField.getSelectedItem();
|
||||||
|
int C_Order_ID = 0;
|
||||||
|
if (pp != null)
|
||||||
|
C_Order_ID = pp.getKey();
|
||||||
|
// set Invoice, RMA and Shipment to Null
|
||||||
|
rmaField.setSelectedIndex(-1);
|
||||||
|
invoiceField.setSelectedIndex(-1);
|
||||||
|
loadOrder(C_Order_ID, false, locatorField.getValue()!=null?((Integer)locatorField.getValue()).intValue():0);
|
||||||
|
}
|
||||||
|
// Invoice
|
||||||
|
else if (e.getSource().equals(invoiceField))
|
||||||
|
{
|
||||||
|
KeyNamePair pp = (KeyNamePair)invoiceField.getSelectedItem();
|
||||||
|
int C_Invoice_ID = 0;
|
||||||
|
if (pp != null)
|
||||||
|
C_Invoice_ID = pp.getKey();
|
||||||
|
// set Order, RMA to Null
|
||||||
|
orderField.setSelectedIndex(-1);
|
||||||
|
rmaField.setSelectedIndex(-1);
|
||||||
|
loadInvoice(C_Invoice_ID, locatorField.getValue()!=null?((Integer)locatorField.getValue()).intValue():0);
|
||||||
|
}
|
||||||
|
// RMA
|
||||||
|
else if (e.getSource().equals(rmaField))
|
||||||
|
{
|
||||||
|
KeyNamePair pp = (KeyNamePair)rmaField.getSelectedItem();
|
||||||
|
int M_RMA_ID = 0;
|
||||||
|
if (pp != null)
|
||||||
|
M_RMA_ID = pp.getKey();
|
||||||
|
// set Order and Invoice to Null
|
||||||
|
orderField.setSelectedIndex(-1);
|
||||||
|
invoiceField.setSelectedIndex(-1);
|
||||||
|
loadRMA(M_RMA_ID, locatorField.getValue()!=null?((Integer)locatorField.getValue()).intValue():0);
|
||||||
|
}
|
||||||
|
//sameWarehouseCb
|
||||||
|
else if (e.getSource().equals(sameWarehouseCb))
|
||||||
|
{
|
||||||
|
initBPOrderDetails(((Integer)bPartnerField.getValue()).intValue(), false);
|
||||||
|
}
|
||||||
|
else if (e.getSource().equals(upcField))
|
||||||
|
{
|
||||||
|
checkProductUsingUPC();
|
||||||
|
}
|
||||||
|
m_actionActive = false;
|
||||||
|
} // actionPerformed
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Change Listener
|
||||||
|
* @param e event
|
||||||
|
*/
|
||||||
|
public void vetoableChange (PropertyChangeEvent e)
|
||||||
|
{
|
||||||
|
log.config(e.getPropertyName() + "=" + e.getNewValue());
|
||||||
|
|
||||||
|
// BPartner - load Order/Invoice/Shipment
|
||||||
|
if (e.getPropertyName().equals("C_BPartner_ID"))
|
||||||
|
{
|
||||||
|
int C_BPartner_ID = ((Integer)e.getNewValue()).intValue();
|
||||||
|
initBPOrderDetails (C_BPartner_ID, false);
|
||||||
|
}
|
||||||
|
dialog.tableChanged(null);
|
||||||
|
} // vetoableChange
|
||||||
|
|
||||||
|
/**************************************************************************
|
||||||
|
* Load BPartner Field
|
||||||
|
* @param forInvoice true if Invoices are to be created, false receipts
|
||||||
|
* @throws Exception if Lookups cannot be initialized
|
||||||
|
*/
|
||||||
|
protected void initBPartner (boolean forInvoice) throws Exception
|
||||||
|
{
|
||||||
|
// load BPartner
|
||||||
|
int AD_Column_ID = 3499; // C_Invoice.C_BPartner_ID
|
||||||
|
MLookup lookup = MLookupFactory.get (Env.getCtx(), p_WindowNo, 0, AD_Column_ID, DisplayType.Search);
|
||||||
|
bPartnerField = new VLookup ("C_BPartner_ID", true, false, true, lookup);
|
||||||
|
//
|
||||||
|
int C_BPartner_ID = Env.getContextAsInt(Env.getCtx(), p_WindowNo, "C_BPartner_ID");
|
||||||
|
bPartnerField.setValue(new Integer(C_BPartner_ID));
|
||||||
|
|
||||||
|
// initial loading
|
||||||
|
initBPOrderDetails(C_BPartner_ID, forInvoice);
|
||||||
|
} // initBPartner
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load PBartner dependent Order/Invoice/Shipment Field.
|
||||||
|
* @param C_BPartner_ID BPartner
|
||||||
|
* @param forInvoice for invoice
|
||||||
|
*/
|
||||||
|
protected void initBPOrderDetails (int C_BPartner_ID, boolean forInvoice)
|
||||||
|
{
|
||||||
|
log.config("C_BPartner_ID=" + C_BPartner_ID);
|
||||||
|
KeyNamePair pp = new KeyNamePair(0,"");
|
||||||
|
// load PO Orders - Closed, Completed
|
||||||
|
orderField.removeActionListener(this);
|
||||||
|
orderField.removeAllItems();
|
||||||
|
orderField.addItem(pp);
|
||||||
|
|
||||||
|
ArrayList<KeyNamePair> list = loadOrderData(C_BPartner_ID, forInvoice, sameWarehouseCb.isSelected());
|
||||||
|
for(KeyNamePair knp : list)
|
||||||
|
orderField.addItem(knp);
|
||||||
|
|
||||||
|
orderField.setSelectedIndex(0);
|
||||||
|
orderField.addActionListener(this);
|
||||||
|
dialog.pack();
|
||||||
|
|
||||||
|
initBPDetails(C_BPartner_ID);
|
||||||
|
} // initBPartnerOIS
|
||||||
|
|
||||||
|
public void initBPDetails(int C_BPartner_ID)
|
||||||
|
{
|
||||||
|
initBPInvoiceDetails(C_BPartner_ID);
|
||||||
|
initBPRMADetails(C_BPartner_ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Init Details - load invoices not shipped
|
||||||
|
* @param C_BPartner_ID BPartner
|
||||||
|
*/
|
||||||
|
private void initBPInvoiceDetails(int C_BPartner_ID)
|
||||||
|
{
|
||||||
|
log.config("C_BPartner_ID" + C_BPartner_ID);
|
||||||
|
|
||||||
|
// load Shipments (Receipts) - Completed, Closed
|
||||||
|
invoiceField.removeActionListener(this);
|
||||||
|
invoiceField.removeAllItems();
|
||||||
|
// None
|
||||||
|
KeyNamePair pp = new KeyNamePair(0,"");
|
||||||
|
invoiceField.addItem(pp);
|
||||||
|
|
||||||
|
ArrayList<KeyNamePair> list = loadInvoiceData(C_BPartner_ID);
|
||||||
|
for(KeyNamePair knp : list)
|
||||||
|
invoiceField.addItem(knp);
|
||||||
|
|
||||||
|
invoiceField.setSelectedIndex(0);
|
||||||
|
invoiceField.addActionListener(this);
|
||||||
|
upcField.addActionListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load RMA that are candidates for shipment
|
||||||
|
* @param C_BPartner_ID BPartner
|
||||||
|
*/
|
||||||
|
private void initBPRMADetails(int C_BPartner_ID)
|
||||||
|
{
|
||||||
|
rmaField.removeActionListener(this);
|
||||||
|
rmaField.removeAllItems();
|
||||||
|
// None
|
||||||
|
KeyNamePair pp = new KeyNamePair(0,"");
|
||||||
|
rmaField.addItem(pp);
|
||||||
|
|
||||||
|
ArrayList<KeyNamePair> list = loadRMAData(C_BPartner_ID);
|
||||||
|
for(KeyNamePair knp : list)
|
||||||
|
rmaField.addItem(knp);
|
||||||
|
|
||||||
|
rmaField.setSelectedIndex(0);
|
||||||
|
rmaField.addActionListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load Data - Order
|
||||||
|
* @param C_Order_ID Order
|
||||||
|
* @param forInvoice true if for invoice vs. delivery qty
|
||||||
|
* @param M_Locator_ID
|
||||||
|
*/
|
||||||
|
protected void loadOrder (int C_Order_ID, boolean forInvoice, int M_Locator_ID)
|
||||||
|
{
|
||||||
|
loadTableOIS(getOrderData(C_Order_ID, forInvoice, M_Locator_ID));
|
||||||
|
} // LoadOrder
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load Data - RMA
|
||||||
|
* @param M_RMA_ID RMA
|
||||||
|
* @param M_Locator_ID
|
||||||
|
*/
|
||||||
|
protected void loadRMA (int M_RMA_ID, int M_Locator_ID)
|
||||||
|
{
|
||||||
|
loadTableOIS(getRMAData(M_RMA_ID, M_Locator_ID));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load Data - Invoice
|
||||||
|
* @param C_Invoice_ID Invoice
|
||||||
|
* @param M_Locator_ID
|
||||||
|
*/
|
||||||
|
protected void loadInvoice (int C_Invoice_ID, int M_Locator_ID)
|
||||||
|
{
|
||||||
|
loadTableOIS(getInvoiceData(C_Invoice_ID, M_Locator_ID));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load Order/Invoice/Shipment data into Table
|
||||||
|
* @param data data
|
||||||
|
*/
|
||||||
|
protected void loadTableOIS (Vector<?> data)
|
||||||
|
{
|
||||||
|
// Remove previous listeners
|
||||||
|
dialog.getMiniTable().getModel().removeTableModelListener(dialog);
|
||||||
|
// Set Model
|
||||||
|
DefaultTableModel model = new DefaultTableModel(data, getOISColumnNames());
|
||||||
|
model.addTableModelListener(dialog);
|
||||||
|
dialog.getMiniTable().setModel(model);
|
||||||
|
//
|
||||||
|
|
||||||
|
configureMiniTable(dialog.getMiniTable());
|
||||||
|
} // loadOrder
|
||||||
|
|
||||||
|
public void showWindow()
|
||||||
|
{
|
||||||
|
dialog.setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void closeWindow()
|
||||||
|
{
|
||||||
|
dialog.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks the UPC value and checks if the UPC matches any of the products in the
|
||||||
|
* list.
|
||||||
|
*/
|
||||||
|
private void checkProductUsingUPC()
|
||||||
|
{
|
||||||
|
String upc = upcField.getText();
|
||||||
|
DefaultTableModel model = (DefaultTableModel)dialog.getMiniTable().getModel();
|
||||||
|
// Lookup UPC
|
||||||
|
List<MProduct> products = MProduct.getByUPC(Env.getCtx(), upc, null);
|
||||||
|
for (MProduct product : products)
|
||||||
|
{
|
||||||
|
int row = findProductRow(product.get_ID());
|
||||||
|
if (row >= 0)
|
||||||
|
{
|
||||||
|
BigDecimal qty = (BigDecimal)model.getValueAt(row, 1);
|
||||||
|
model.setValueAt(qty, row, 1);
|
||||||
|
model.setValueAt(Boolean.TRUE, row, 0);
|
||||||
|
model.fireTableRowsUpdated(row, row);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
upcField.setText("");
|
||||||
|
upcField.requestFocusInWindow();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds the row where a given product is. If the product is not found
|
||||||
|
* in the table -1 is returned.
|
||||||
|
* @param M_Product_ID
|
||||||
|
* @return Row of the product or -1 if non existing.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private int findProductRow(int M_Product_ID)
|
||||||
|
{
|
||||||
|
DefaultTableModel model = (DefaultTableModel)dialog.getMiniTable().getModel();
|
||||||
|
KeyNamePair kp;
|
||||||
|
for (int i=0; i<model.getRowCount(); i++) {
|
||||||
|
kp = (KeyNamePair)model.getValueAt(i, 4);
|
||||||
|
if (kp.getKey()==M_Product_ID) {
|
||||||
|
return(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -51,7 +51,7 @@ public class WCreateFromFactory
|
||||||
s_registeredClasses.put(I_C_Invoice.Table_ID, WCreateFromInvoiceUI.class);
|
s_registeredClasses.put(I_C_Invoice.Table_ID, WCreateFromInvoiceUI.class);
|
||||||
|
|
||||||
s_registeredClasses.put(I_C_BankStatement.Table_ID, WCreateFromStatementUI.class);
|
s_registeredClasses.put(I_C_BankStatement.Table_ID, WCreateFromStatementUI.class);
|
||||||
s_registeredClasses.put(I_M_InOut.Table_ID, WCreateFromShipment.class);
|
s_registeredClasses.put(I_M_InOut.Table_ID, WCreateFromShipmentUI.class);
|
||||||
s_registeredClasses.put(I_M_RMA.Table_ID, WCreateFromRMA.class);
|
s_registeredClasses.put(I_M_RMA.Table_ID, WCreateFromRMA.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,556 @@
|
||||||
|
/******************************************************************************
|
||||||
|
* Copyright (C) 2009 Low Heng Sin *
|
||||||
|
* Copyright (C) 2009 Idalica Corporation *
|
||||||
|
* This program is free software; you can redistribute it and/or modify it *
|
||||||
|
* under the terms version 2 of the GNU General Public License as published *
|
||||||
|
* by the Free Software Foundation. This program is distributed in the hope *
|
||||||
|
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||||
|
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||||
|
* See the GNU General Public License for more details. *
|
||||||
|
* You should have received a copy of the GNU General Public License along *
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
package org.adempiere.webui.apps.form;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Vector;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
import javax.swing.JComboBox;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JTextField;
|
||||||
|
import javax.swing.table.DefaultTableModel;
|
||||||
|
|
||||||
|
import org.adempiere.webui.apps.AEnv;
|
||||||
|
import org.adempiere.webui.component.Checkbox;
|
||||||
|
import org.adempiere.webui.component.Grid;
|
||||||
|
import org.adempiere.webui.component.GridFactory;
|
||||||
|
import org.adempiere.webui.component.Label;
|
||||||
|
import org.adempiere.webui.component.ListItem;
|
||||||
|
import org.adempiere.webui.component.ListModelTable;
|
||||||
|
import org.adempiere.webui.component.Listbox;
|
||||||
|
import org.adempiere.webui.component.ListboxFactory;
|
||||||
|
import org.adempiere.webui.component.Panel;
|
||||||
|
import org.adempiere.webui.component.Row;
|
||||||
|
import org.adempiere.webui.component.Rows;
|
||||||
|
import org.adempiere.webui.editor.WEditor;
|
||||||
|
import org.adempiere.webui.editor.WLocatorEditor;
|
||||||
|
import org.adempiere.webui.editor.WSearchEditor;
|
||||||
|
import org.adempiere.webui.editor.WStringEditor;
|
||||||
|
import org.adempiere.webui.event.ValueChangeEvent;
|
||||||
|
import org.adempiere.webui.event.ValueChangeListener;
|
||||||
|
import org.compiere.grid.CreateFromShipment;
|
||||||
|
import org.compiere.model.GridTab;
|
||||||
|
import org.compiere.model.MDocType;
|
||||||
|
import org.compiere.model.MInvoice;
|
||||||
|
import org.compiere.model.MLocatorLookup;
|
||||||
|
import org.compiere.model.MLookup;
|
||||||
|
import org.compiere.model.MLookupFactory;
|
||||||
|
import org.compiere.model.MProduct;
|
||||||
|
import org.compiere.model.MRMA;
|
||||||
|
import org.compiere.util.CLogger;
|
||||||
|
import org.compiere.util.DisplayType;
|
||||||
|
import org.compiere.util.Env;
|
||||||
|
import org.compiere.util.KeyNamePair;
|
||||||
|
import org.compiere.util.Msg;
|
||||||
|
import org.zkoss.zk.ui.event.Event;
|
||||||
|
import org.zkoss.zk.ui.event.EventListener;
|
||||||
|
import org.zkoss.zk.ui.event.Events;
|
||||||
|
import org.zkoss.zkex.zul.Borderlayout;
|
||||||
|
import org.zkoss.zkex.zul.Center;
|
||||||
|
import org.zkoss.zul.Space;
|
||||||
|
|
||||||
|
public class WCreateFromShipmentUI extends CreateFromShipment implements EventListener, ValueChangeListener
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private WCreateFromWindow window;
|
||||||
|
|
||||||
|
public WCreateFromShipmentUI(GridTab tab)
|
||||||
|
{
|
||||||
|
super(tab);
|
||||||
|
log.info(getGridTab().toString());
|
||||||
|
|
||||||
|
window = new WCreateFromWindow(this, getGridTab().getWindowNo());
|
||||||
|
|
||||||
|
p_WindowNo = getGridTab().getWindowNo();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!dynInit())
|
||||||
|
return;
|
||||||
|
zkInit();
|
||||||
|
setInitOK(true);
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
log.log(Level.SEVERE, "", e);
|
||||||
|
setInitOK(false);
|
||||||
|
}
|
||||||
|
AEnv.showWindow(window);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Window No */
|
||||||
|
private int p_WindowNo;
|
||||||
|
|
||||||
|
/** Logger */
|
||||||
|
private CLogger log = CLogger.getCLogger(getClass());
|
||||||
|
|
||||||
|
protected Label bPartnerLabel = new Label();
|
||||||
|
protected WEditor bPartnerField;
|
||||||
|
|
||||||
|
protected Label orderLabel = new Label();
|
||||||
|
protected Listbox orderField = ListboxFactory.newDropdownListbox();
|
||||||
|
|
||||||
|
/** Label for the rma selection */
|
||||||
|
protected Label rmaLabel = new Label();
|
||||||
|
/** Combo box for selecting RMA document */
|
||||||
|
protected Listbox rmaField = ListboxFactory.newDropdownListbox();
|
||||||
|
|
||||||
|
protected Label invoiceLabel = new Label();
|
||||||
|
protected Listbox invoiceField = ListboxFactory.newDropdownListbox();
|
||||||
|
protected Checkbox sameWarehouseCb = new Checkbox();
|
||||||
|
protected Label locatorLabel = new Label();
|
||||||
|
protected WLocatorEditor locatorField = new WLocatorEditor();
|
||||||
|
protected Label upcLabel = new Label();
|
||||||
|
protected WStringEditor upcField = new WStringEditor();
|
||||||
|
/** Loaded Invoice */
|
||||||
|
private MInvoice m_invoice = null;
|
||||||
|
/** Loaded RMA */
|
||||||
|
private MRMA m_rma = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dynamic Init
|
||||||
|
* @throws Exception if Lookups cannot be initialized
|
||||||
|
* @return true if initialized
|
||||||
|
*/
|
||||||
|
public boolean dynInit() throws Exception
|
||||||
|
{
|
||||||
|
log.config("");
|
||||||
|
|
||||||
|
super.dynInit();
|
||||||
|
|
||||||
|
window.setTitle(getTitle());
|
||||||
|
|
||||||
|
sameWarehouseCb.setSelected(true);
|
||||||
|
sameWarehouseCb.addActionListener(this);
|
||||||
|
// load Locator
|
||||||
|
MLocatorLookup locator = new MLocatorLookup(Env.getCtx(), p_WindowNo);
|
||||||
|
locatorField = new WLocatorEditor ("M_Locator_ID", true, false, true, locator, p_WindowNo);
|
||||||
|
|
||||||
|
initBPartner(false);
|
||||||
|
bPartnerField.addValueChangeListener(this);
|
||||||
|
locatorLabel.setMandatory(true);
|
||||||
|
|
||||||
|
upcField = new WStringEditor ("UPC", false, false, true, 10, 30, null, null);
|
||||||
|
upcField.getComponent().addEventListener(Events.ON_CHANGE, this);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} // dynInit
|
||||||
|
|
||||||
|
protected void zkInit() throws Exception
|
||||||
|
{
|
||||||
|
bPartnerLabel.setText(Msg.getElement(Env.getCtx(), "C_BPartner_ID"));
|
||||||
|
orderLabel.setText(Msg.getElement(Env.getCtx(), "C_Order_ID", false));
|
||||||
|
invoiceLabel.setText(Msg.getElement(Env.getCtx(), "C_Invoice_ID", false));
|
||||||
|
rmaLabel.setText(Msg.translate(Env.getCtx(), "M_RMA_ID"));
|
||||||
|
locatorLabel.setText(Msg.translate(Env.getCtx(), "M_Locator_ID"));
|
||||||
|
sameWarehouseCb.setText(Msg.getMsg(Env.getCtx(), "FromSameWarehouseOnly", true));
|
||||||
|
sameWarehouseCb.setTooltiptext(Msg.getMsg(Env.getCtx(), "FromSameWarehouseOnly", false));
|
||||||
|
upcLabel.setText(Msg.getElement(Env.getCtx(), "UPC", false));
|
||||||
|
|
||||||
|
Borderlayout parameterLayout = new Borderlayout();
|
||||||
|
parameterLayout.setHeight("110px");
|
||||||
|
parameterLayout.setWidth("100%");
|
||||||
|
Panel parameterPanel = window.getParameterPanel();
|
||||||
|
parameterPanel.appendChild(parameterLayout);
|
||||||
|
|
||||||
|
Grid parameterStdLayout = GridFactory.newGridLayout();
|
||||||
|
Panel parameterStdPanel = new Panel();
|
||||||
|
parameterStdPanel.appendChild(parameterStdLayout);
|
||||||
|
|
||||||
|
Center center = new Center();
|
||||||
|
parameterLayout.appendChild(center);
|
||||||
|
center.appendChild(parameterStdPanel);
|
||||||
|
|
||||||
|
parameterStdPanel.appendChild(parameterStdLayout);
|
||||||
|
Rows rows = (Rows) parameterStdLayout.newRows();
|
||||||
|
Row row = rows.newRow();
|
||||||
|
row.appendChild(bPartnerLabel.rightAlign());
|
||||||
|
if (bPartnerField != null)
|
||||||
|
row.appendChild(bPartnerField.getComponent());
|
||||||
|
row.appendChild(orderLabel.rightAlign());
|
||||||
|
row.appendChild(orderField);
|
||||||
|
|
||||||
|
row = rows.newRow();
|
||||||
|
row.appendChild(locatorLabel.rightAlign());
|
||||||
|
row.appendChild(locatorField.getComponent());
|
||||||
|
row.appendChild(invoiceLabel.rightAlign());
|
||||||
|
row.appendChild(invoiceField);
|
||||||
|
|
||||||
|
row = rows.newRow();
|
||||||
|
row.appendChild(new Space());
|
||||||
|
row.appendChild(sameWarehouseCb);
|
||||||
|
|
||||||
|
// Add RMA document selection to panel
|
||||||
|
row = rows.newRow();
|
||||||
|
row.appendChild(upcLabel.rightAlign());
|
||||||
|
row.appendChild(upcField.getComponent());
|
||||||
|
row.appendChild(rmaLabel.rightAlign());
|
||||||
|
row.appendChild(rmaField);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean m_actionActive = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action Listener
|
||||||
|
* @param e event
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public void onEvent(Event e) throws Exception
|
||||||
|
{
|
||||||
|
if (m_actionActive)
|
||||||
|
return;
|
||||||
|
m_actionActive = true;
|
||||||
|
/*
|
||||||
|
// Order
|
||||||
|
if (e.getTarget().equals(orderField))
|
||||||
|
{
|
||||||
|
ListItem li = orderField.getSelectedItem();
|
||||||
|
int C_Order_ID = 0;
|
||||||
|
if (li != null && li.getValue() != null)
|
||||||
|
C_Order_ID = ((Integer) li.getValue()).intValue();
|
||||||
|
// set Invoice, RMA and Shipment to Null
|
||||||
|
rmaField.setSelectedIndex(-1);
|
||||||
|
//shipmentField.setSelectedIndex(-1);
|
||||||
|
loadOrder(C_Order_ID, true);
|
||||||
|
}
|
||||||
|
// Shipment
|
||||||
|
else if (e.getTarget().equals(invoiceField))
|
||||||
|
{
|
||||||
|
ListItem li = shipmentField.getSelectedItem();
|
||||||
|
int M_InOut_ID = 0;
|
||||||
|
if (li != null && li.getValue() != null)
|
||||||
|
M_InOut_ID = ((Integer) li.getValue()).intValue();
|
||||||
|
// set Order, RMA and Invoice to Null
|
||||||
|
orderField.setSelectedIndex(-1);
|
||||||
|
rmaField.setSelectedIndex(-1);
|
||||||
|
loadShipment(M_InOut_ID);
|
||||||
|
}
|
||||||
|
// RMA
|
||||||
|
else if (e.getTarget().equals(rmaField))
|
||||||
|
{
|
||||||
|
ListItem li = rmaField.getSelectedItem();
|
||||||
|
int M_RMA_ID = 0;
|
||||||
|
if (li != null && li.getValue() != null)
|
||||||
|
M_RMA_ID = ((Integer) li.getValue()).intValue();
|
||||||
|
// set Order and Invoice to Null
|
||||||
|
orderField.setSelectedIndex(-1);
|
||||||
|
//shipmentField.setSelectedIndex(-1);
|
||||||
|
loadRMA(M_RMA_ID);
|
||||||
|
}
|
||||||
|
m_actionActive = false;
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Order
|
||||||
|
if (e.getTarget().equals(orderField))
|
||||||
|
{
|
||||||
|
KeyNamePair pp = orderField.getSelectedItem().toKeyNamePair();
|
||||||
|
if (pp == null || pp.getKey() == 0)
|
||||||
|
;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int C_Order_ID = pp.getKey();
|
||||||
|
// set Invoice and Shipment to Null
|
||||||
|
invoiceField.setSelectedIndex(-1);
|
||||||
|
rmaField.setSelectedIndex(-1);
|
||||||
|
loadOrder(C_Order_ID, false, locatorField.getValue()!=null?((Integer)locatorField.getValue()).intValue():0);
|
||||||
|
m_invoice = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Invoice
|
||||||
|
else if (e.getTarget().equals(invoiceField))
|
||||||
|
{
|
||||||
|
KeyNamePair pp = invoiceField.getSelectedItem().toKeyNamePair();
|
||||||
|
if (pp == null || pp.getKey() == 0)
|
||||||
|
;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int C_Invoice_ID = pp.getKey();
|
||||||
|
// set Order and Shipment to Null
|
||||||
|
orderField.setSelectedIndex(-1);
|
||||||
|
rmaField.setSelectedIndex(-1);
|
||||||
|
loadInvoice(C_Invoice_ID, locatorField.getValue()!=null?((Integer)locatorField.getValue()).intValue():0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// RMA
|
||||||
|
else if (e.getTarget().equals(rmaField))
|
||||||
|
{
|
||||||
|
KeyNamePair pp = rmaField.getSelectedItem().toKeyNamePair();
|
||||||
|
if (pp == null || pp.getKey() == 0)
|
||||||
|
;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int M_RMA_ID = pp.getKey();
|
||||||
|
// set Order and Shipment to Null
|
||||||
|
orderField.setSelectedIndex(-1);
|
||||||
|
invoiceField.setSelectedIndex(-1);
|
||||||
|
loadRMA(M_RMA_ID, locatorField.getValue()!=null?((Integer)locatorField.getValue()).intValue():0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//sameWarehouseCb
|
||||||
|
else if (e.getTarget().equals(sameWarehouseCb))
|
||||||
|
{
|
||||||
|
initBPOrderDetails(((Integer)bPartnerField.getValue()).intValue(), false);
|
||||||
|
}
|
||||||
|
else if (e.getTarget().equals(upcField.getComponent()))
|
||||||
|
{
|
||||||
|
checkProductUsingUPC();
|
||||||
|
}
|
||||||
|
|
||||||
|
m_actionActive = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks the UPC value and checks if the UPC matches any of the products in the
|
||||||
|
* list.
|
||||||
|
*/
|
||||||
|
private void checkProductUsingUPC()
|
||||||
|
{
|
||||||
|
String upc = upcField.getDisplay();
|
||||||
|
//DefaultTableModel model = (DefaultTableModel) dialog.getMiniTable().getModel();
|
||||||
|
ListModelTable model = (ListModelTable) window.getWListbox().getModel();
|
||||||
|
|
||||||
|
// Lookup UPC
|
||||||
|
List<MProduct> products = MProduct.getByUPC(Env.getCtx(), upc, null);
|
||||||
|
for (MProduct product : products)
|
||||||
|
{
|
||||||
|
int row = findProductRow(product.get_ID());
|
||||||
|
if (row >= 0)
|
||||||
|
{
|
||||||
|
BigDecimal qty = (BigDecimal)model.getValueAt(row, 1);
|
||||||
|
model.setValueAt(qty, row, 1);
|
||||||
|
model.setValueAt(Boolean.TRUE, row, 0);
|
||||||
|
model.updateComponent(row, row);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
upcField.setValue("");
|
||||||
|
upcField.setHasFocus(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds the row where a given product is. If the product is not found
|
||||||
|
* in the table -1 is returned.
|
||||||
|
* @param M_Product_ID
|
||||||
|
* @return Row of the product or -1 if non existing.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private int findProductRow(int M_Product_ID)
|
||||||
|
{
|
||||||
|
//DefaultTableModel model = (DefaultTableModel)dialog.getMiniTable().getModel();
|
||||||
|
ListModelTable model = (ListModelTable) window.getWListbox().getModel();
|
||||||
|
KeyNamePair kp;
|
||||||
|
for (int i=0; i<model.getRowCount(); i++) {
|
||||||
|
kp = (KeyNamePair)model.getValueAt(i, 4);
|
||||||
|
if (kp.getKey()==M_Product_ID) {
|
||||||
|
return(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Change Listener
|
||||||
|
* @param e event
|
||||||
|
*/
|
||||||
|
public void valueChange (ValueChangeEvent e)
|
||||||
|
{
|
||||||
|
log.config(e.getPropertyName() + "=" + e.getNewValue());
|
||||||
|
|
||||||
|
// BPartner - load Order/Invoice/Shipment
|
||||||
|
if (e.getPropertyName().equals("C_BPartner_ID"))
|
||||||
|
{
|
||||||
|
int C_BPartner_ID = ((Integer)e.getNewValue()).intValue();
|
||||||
|
initBPOrderDetails (C_BPartner_ID, true);
|
||||||
|
}
|
||||||
|
window.tableChanged(null);
|
||||||
|
} // vetoableChange
|
||||||
|
|
||||||
|
/**************************************************************************
|
||||||
|
* Load BPartner Field
|
||||||
|
* @param forInvoice true if Invoices are to be created, false receipts
|
||||||
|
* @throws Exception if Lookups cannot be initialized
|
||||||
|
*/
|
||||||
|
protected void initBPartner (boolean forInvoice) throws Exception
|
||||||
|
{
|
||||||
|
// load BPartner
|
||||||
|
int AD_Column_ID = 3499; // C_Invoice.C_BPartner_ID
|
||||||
|
MLookup lookup = MLookupFactory.get (Env.getCtx(), p_WindowNo, 0, AD_Column_ID, DisplayType.Search);
|
||||||
|
bPartnerField = new WSearchEditor ("C_BPartner_ID", true, false, true, lookup);
|
||||||
|
//
|
||||||
|
int C_BPartner_ID = Env.getContextAsInt(Env.getCtx(), p_WindowNo, "C_BPartner_ID");
|
||||||
|
bPartnerField.setValue(new Integer(C_BPartner_ID));
|
||||||
|
|
||||||
|
// initial loading
|
||||||
|
initBPOrderDetails(C_BPartner_ID, forInvoice);
|
||||||
|
} // initBPartner
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Init Details - load invoices not shipped
|
||||||
|
* @param C_BPartner_ID BPartner
|
||||||
|
*/
|
||||||
|
private void initBPInvoiceDetails(int C_BPartner_ID)
|
||||||
|
{
|
||||||
|
log.config("C_BPartner_ID" + C_BPartner_ID);
|
||||||
|
|
||||||
|
// load Shipments (Receipts) - Completed, Closed
|
||||||
|
invoiceField.removeActionListener(this);
|
||||||
|
invoiceField.removeAllItems();
|
||||||
|
// None
|
||||||
|
KeyNamePair pp = new KeyNamePair(0,"");
|
||||||
|
invoiceField.addItem(pp);
|
||||||
|
|
||||||
|
ArrayList<KeyNamePair> list = loadInvoiceData(C_BPartner_ID);
|
||||||
|
for(KeyNamePair knp : list)
|
||||||
|
invoiceField.addItem(knp);
|
||||||
|
|
||||||
|
invoiceField.setSelectedIndex(0);
|
||||||
|
invoiceField.addActionListener(this);
|
||||||
|
upcField.addValueChangeListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load PBartner dependent Order/Invoice/Shipment Field.
|
||||||
|
* @param C_BPartner_ID BPartner
|
||||||
|
* @param forInvoice for invoice
|
||||||
|
*/
|
||||||
|
protected void initBPOrderDetails (int C_BPartner_ID, boolean forInvoice)
|
||||||
|
{
|
||||||
|
log.config("C_BPartner_ID=" + C_BPartner_ID);
|
||||||
|
KeyNamePair pp = new KeyNamePair(0,"");
|
||||||
|
// load PO Orders - Closed, Completed
|
||||||
|
orderField.removeActionListener(this);
|
||||||
|
orderField.removeAllItems();
|
||||||
|
orderField.addItem(pp);
|
||||||
|
|
||||||
|
ArrayList<KeyNamePair> list = loadOrderData(C_BPartner_ID, forInvoice, false);
|
||||||
|
for(KeyNamePair knp : list)
|
||||||
|
orderField.addItem(knp);
|
||||||
|
|
||||||
|
orderField.setSelectedIndex(0);
|
||||||
|
orderField.addActionListener(this);
|
||||||
|
|
||||||
|
initBPDetails(C_BPartner_ID);
|
||||||
|
} // initBPartnerOIS
|
||||||
|
|
||||||
|
public void initBPDetails(int C_BPartner_ID)
|
||||||
|
{
|
||||||
|
initBPInvoiceDetails(C_BPartner_ID);
|
||||||
|
initBPRMADetails(C_BPartner_ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load RMA that are candidates for shipment
|
||||||
|
* @param C_BPartner_ID BPartner
|
||||||
|
*/
|
||||||
|
private void initBPRMADetails(int C_BPartner_ID)
|
||||||
|
{
|
||||||
|
rmaField.removeActionListener(this);
|
||||||
|
rmaField.removeAllItems();
|
||||||
|
// None
|
||||||
|
KeyNamePair pp = new KeyNamePair(0,"");
|
||||||
|
rmaField.addItem(pp);
|
||||||
|
|
||||||
|
ArrayList<KeyNamePair> list = loadRMAData(C_BPartner_ID);
|
||||||
|
for(KeyNamePair knp : list)
|
||||||
|
rmaField.addItem(knp);
|
||||||
|
|
||||||
|
rmaField.setSelectedIndex(0);
|
||||||
|
rmaField.addActionListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load Data - Order
|
||||||
|
* @param C_Order_ID Order
|
||||||
|
* @param forInvoice true if for invoice vs. delivery qty
|
||||||
|
*/
|
||||||
|
/* protected void loadOrder (int C_Order_ID, boolean forInvoice)
|
||||||
|
{
|
||||||
|
loadTableOIS(getOrderData(C_Order_ID, forInvoice));
|
||||||
|
} // LoadOrder
|
||||||
|
|
||||||
|
protected void loadRMA (int M_RMA_ID)
|
||||||
|
{
|
||||||
|
loadTableOIS(getRMAData(M_RMA_ID));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void loadShipment (int M_InOut_ID)
|
||||||
|
{
|
||||||
|
loadTableOIS(getShipmentData(M_InOut_ID));
|
||||||
|
}*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load Data - Order
|
||||||
|
* @param C_Order_ID Order
|
||||||
|
* @param forInvoice true if for invoice vs. delivery qty
|
||||||
|
* @param M_Locator_ID
|
||||||
|
*/
|
||||||
|
protected void loadOrder (int C_Order_ID, boolean forInvoice, int M_Locator_ID)
|
||||||
|
{
|
||||||
|
loadTableOIS(getOrderData(C_Order_ID, forInvoice, M_Locator_ID));
|
||||||
|
} // LoadOrder
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load Data - RMA
|
||||||
|
* @param M_RMA_ID RMA
|
||||||
|
* @param M_Locator_ID
|
||||||
|
*/
|
||||||
|
protected void loadRMA (int M_RMA_ID, int M_Locator_ID)
|
||||||
|
{
|
||||||
|
loadTableOIS(getRMAData(M_RMA_ID, M_Locator_ID));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load Data - Invoice
|
||||||
|
* @param C_Invoice_ID Invoice
|
||||||
|
* @param M_Locator_ID
|
||||||
|
*/
|
||||||
|
protected void loadInvoice (int C_Invoice_ID, int M_Locator_ID)
|
||||||
|
{
|
||||||
|
loadTableOIS(getInvoiceData(C_Invoice_ID, M_Locator_ID));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load Order/Invoice/Shipment data into Table
|
||||||
|
* @param data data
|
||||||
|
*/
|
||||||
|
protected void loadTableOIS (Vector<?> data)
|
||||||
|
{
|
||||||
|
window.getWListbox().clear();
|
||||||
|
|
||||||
|
// Remove previous listeners
|
||||||
|
window.getWListbox().getModel().removeTableModelListener(window);
|
||||||
|
// Set Model
|
||||||
|
ListModelTable model = new ListModelTable(data);
|
||||||
|
model.addTableModelListener(window);
|
||||||
|
window.getWListbox().setData(model, getOISColumnNames());
|
||||||
|
//
|
||||||
|
|
||||||
|
configureMiniTable(window.getWListbox());
|
||||||
|
} // loadOrder
|
||||||
|
|
||||||
|
public void showWindow()
|
||||||
|
{
|
||||||
|
window.setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void closeWindow()
|
||||||
|
{
|
||||||
|
window.dispose();
|
||||||
|
}
|
||||||
|
}
|
|
@ -92,9 +92,9 @@ public class WLocatorEditor extends WEditor implements EventListener, PropertyCh
|
||||||
m_mLocator = mLocator;
|
m_mLocator = mLocator;
|
||||||
getComponent().setButtonImage("/images/Locator10.png");
|
getComponent().setButtonImage("/images/Locator10.png");
|
||||||
|
|
||||||
|
m_WindowNo = windowNo; //Yvonne: move it b4 setDefault_Locator_ID()
|
||||||
setDefault_Locator_ID(); // set default locator, teo_sarca [ 1661546 ]
|
setDefault_Locator_ID(); // set default locator, teo_sarca [ 1661546 ]
|
||||||
|
|
||||||
m_WindowNo = windowNo;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue