use of org.compiere.util.KeyNamePair in project adempiere by adempiere.
the class VCreateFromShipmentUI method actionPerformed.
/**
* 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);
} else // Invoice
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);
} else // RMA
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);
} else //sameWarehouseCb
if (e.getSource().equals(sameWarehouseCb)) {
initBPOrderDetails(((Integer) bPartnerField.getValue()).intValue(), false);
} else if (e.getSource().equals(upcField)) {
checkProductUsingUPC();
}
m_actionActive = false;
}
use of org.compiere.util.KeyNamePair in project adempiere by adempiere.
the class VInOutInvoiceGen method generateInvoices.
// generateShipments_complete
/**************************************************************************
* Generate Invoices
*/
private void generateInvoices() {
String trxName = Trx.createTrxName("IVG");
//trx needs to be committed too
Trx trx = Trx.get(trxName, true);
//String trxName = null;
//Trx trx = null;
// prevents from being called twice
m_selectionActive = false;
statusBar.setStatusLine(Msg.getMsg(Env.getCtx(), "InvGenerateGen"));
statusBar.setStatusDB(String.valueOf(selection.size()));
// Prepare Process
int AD_Process_ID = 0;
KeyNamePair docTypeKNPair = (KeyNamePair) cmbDocType.getSelectedItem();
if (docTypeKNPair.getKey() == MRMA.Table_ID) {
// C_Invoice_GenerateRMA - org.adempiere.process.InvoiceGenerateRMA
AD_Process_ID = 52002;
} else {
// HARDCODED C_InvoiceCreate
AD_Process_ID = 134;
}
MPInstance instance = new MPInstance(Env.getCtx(), AD_Process_ID, 0);
if (!instance.save()) {
info.setText(Msg.getMsg(Env.getCtx(), "ProcessNoInstance"));
return;
}
//insert selection
/*Selection exist from shipment*/
StringBuffer insert = new StringBuffer();
insert.append("INSERT INTO T_SELECTION(AD_PINSTANCE_ID, T_SELECTION_ID) ");
int counter = 0;
for (Integer selectedId : selection) {
counter++;
if (counter > 1)
insert.append(" UNION ");
insert.append("SELECT ");
insert.append(instance.getAD_PInstance_ID());
insert.append(", ");
insert.append(selectedId);
insert.append(" FROM DUAL ");
if (counter == 1000) {
if (DB.executeUpdate(insert.toString(), trxName) < 0) {
// not translated!
String msg = "No Shipments";
log.config(msg);
info.setText(msg);
trx.rollback();
return;
}
insert = new StringBuffer();
insert.append("INSERT INTO T_SELECTION(AD_PINSTANCE_ID, T_SELECTION_ID) ");
counter = 0;
}
}
if (counter > 0) {
if (DB.executeUpdate(insert.toString(), trxName) < 0) {
// not translated!
String msg = "No Shipments";
log.config(msg);
info.setText(msg);
trx.rollback();
return;
}
}
ProcessInfo pi = new ProcessInfo("", AD_Process_ID);
pi.setAD_PInstance_ID(instance.getAD_PInstance_ID());
// Add Parameters
MPInstancePara para = new MPInstancePara(instance, 10);
para.setParameter("Selection", "Y");
if (!para.save()) {
// not translated
String msg = "No Selection Parameter added";
info.setText(msg);
log.log(Level.SEVERE, msg);
return;
}
para = new MPInstancePara(instance, 20);
para.setParameter("DocAction", "CO");
if (!para.save()) {
// not translated
String msg = "No DocAction Parameter added";
info.setText(msg);
log.log(Level.SEVERE, msg);
return;
}
// Execute Process
ProcessCtl worker = new ProcessCtl(this, Env.getWindowNo(this), pi, trx);
// complete tasks in unlockUI / generateInvoice_complete
worker.start();
}
use of org.compiere.util.KeyNamePair in project adempiere by adempiere.
the class VInOutInvoiceGen method generateShipments.
// saveSelection
/**************************************************************************
* Generate Shipments
*/
private void generateShipments() {
log.info("M_Warehouse_ID=" + m_M_Warehouse_ID);
String trxName = Trx.createTrxName("IOG");
//trx needs to be committed too
Trx trx = Trx.get(trxName, true);
//String trxName = null;
//Trx trx = null;
// prevents from being called twice
m_selectionActive = false;
statusBar.setStatusLine(Msg.getMsg(Env.getCtx(), "InOutGenerateGen"));
statusBar.setStatusDB(String.valueOf(selection.size()));
// Prepare Process
int AD_Process_ID = 0;
KeyNamePair docTypeKNPair = (KeyNamePair) cmbDocType.getSelectedItem();
if (docTypeKNPair.getKey() == MRMA.Table_ID) {
// M_InOut_GenerateRMA - org.adempiere.process.InOutGenerateRMA
AD_Process_ID = 52001;
} else {
// M_InOut_Generate - org.compiere.process.InOutGenerate
AD_Process_ID = 199;
}
MPInstance instance = new MPInstance(Env.getCtx(), AD_Process_ID, 0);
if (!instance.save()) {
info.setText(Msg.getMsg(Env.getCtx(), "ProcessNoInstance"));
return;
}
//insert selection
StringBuffer insert = new StringBuffer();
insert.append("INSERT INTO T_SELECTION(AD_PINSTANCE_ID, T_SELECTION_ID) ");
int counter = 0;
for (Integer selectedId : selection) {
counter++;
if (counter > 1)
insert.append(" UNION ");
insert.append("SELECT ");
insert.append(instance.getAD_PInstance_ID());
insert.append(", ");
insert.append(selectedId);
insert.append(" FROM DUAL ");
if (counter == 1000) {
if (DB.executeUpdate(insert.toString(), trxName) < 0) {
// not translated!
String msg = "No Shipments";
log.config(msg);
info.setText(msg);
trx.rollback();
return;
}
insert = new StringBuffer();
insert.append("INSERT INTO T_SELECTION(AD_PINSTANCE_ID, T_SELECTION_ID) ");
counter = 0;
}
}
if (counter > 0) {
if (DB.executeUpdate(insert.toString(), trxName) < 0) {
// not translated!
String msg = "No Shipments";
log.config(msg);
info.setText(msg);
trx.rollback();
return;
}
}
//call process
ProcessInfo pi = new ProcessInfo("VInOutGen", AD_Process_ID);
pi.setAD_PInstance_ID(instance.getAD_PInstance_ID());
// Add Parameter - Selection=Y
MPInstancePara ip = new MPInstancePara(instance, 10);
ip.setParameter("Selection", "Y");
if (!ip.save()) {
// not translated
String msg = "No Parameter added";
info.setText(msg);
log.log(Level.SEVERE, msg);
return;
}
// Add Parameter - M_Warehouse_ID=x
ip = new MPInstancePara(instance, 20);
ip.setParameter("M_Warehouse_ID", Integer.parseInt(m_M_Warehouse_ID.toString()));
if (!ip.save()) {
// not translated
String msg = "No Parameter added";
info.setText(msg);
log.log(Level.SEVERE, msg);
return;
}
// Execute Process
ProcessCtl worker = new ProcessCtl(this, Env.getWindowNo(this), pi, trx);
// complete tasks in unlockUI / generateShipments_complete
worker.start();
//
}
use of org.compiere.util.KeyNamePair in project adempiere by adempiere.
the class ModelADServiceImpl method modelLogin.
private String modelLogin(ADLoginRequest r, String webService, String method, String serviceType) throws XFireFault {
// TODO: Share login between different sessions
if (m_cs.isLoggedIn() && m_cs.getM_AD_Client_ID() == r.getClientID() && m_cs.getM_AD_Org_ID() == r.getOrgID() && m_cs.getM_AD_Role_ID() == r.getRoleID() && m_cs.getM_AD_Warehouse_ID() == r.getWarehouseID() && r.getUser().equals(m_cs.getUser()))
// already logged with same data
return authenticate(webService, method, serviceType);
Login login = new Login(m_cs.getM_ctx());
KeyNamePair[] roles = login.getRoles(r.getUser(), r.getPass());
if (roles != null) {
boolean okrole = false;
for (KeyNamePair role : roles) {
if (role.getKey() == r.getRoleID()) {
okrole = true;
break;
}
}
if (!okrole)
return "Error logging in - role not allowed for this user";
KeyNamePair[] clients = login.getClients(new KeyNamePair(r.getRoleID(), ""));
boolean okclient = false;
for (KeyNamePair client : clients) {
if (client.getKey() == r.getClientID()) {
okclient = true;
break;
}
}
if (!okclient)
return "Error logging in - client not allowed for this role";
KeyNamePair[] orgs = login.getOrgs(new KeyNamePair(r.getClientID(), ""));
if (orgs == null)
return "Error logging in - no organizations for this role";
KeyNamePair orglogin = null;
boolean okorg = false;
for (KeyNamePair org : orgs) {
if (org.getKey() == r.getOrgID()) {
okorg = true;
orglogin = org;
break;
}
}
if (!okorg)
return "Error logging in - org not allowed for this role";
KeyNamePair[] warehouses = login.getWarehouses(new KeyNamePair(r.getOrgID(), ""));
boolean okwh = false;
if (warehouses != null) {
for (KeyNamePair warehouse : warehouses) {
if (warehouse.getKey() == r.getWarehouseID()) {
okwh = true;
break;
}
}
if (!okwh)
return "Error logging in - warehouse not allowed for this org";
}
String error = login.validateLogin(orglogin);
if (error != null && error.length() > 0)
return error;
int AD_User_ID = Env.getAD_User_ID(m_cs.getM_ctx());
if (!m_cs.login(AD_User_ID, r.getRoleID(), r.getClientID(), r.getOrgID(), r.getWarehouseID(), r.getLang()))
return "Error logging in";
} else {
return "Error logging in - no roles or user/pwd invalid for user " + r.getUser();
}
return authenticate(webService, method, serviceType);
}
use of org.compiere.util.KeyNamePair in project adempiere by adempiere.
the class LoginDynUpdate method reply_Login2_Role.
// getReply
/**
* Login 2nd page Response - Field Role.
* <p>
* fill Client, Org, Warehouse
* @param body document body
* @param wsc web session context
* @param formName
* @param fieldValue
*/
private static void reply_Login2_Role(body body, MobileSessionCtx wsc, String roleId) {
// Formname
String form = null;
Login login = new Login(wsc.ctx);
// Get Data
KeyNamePair[] clients = login.getClients(new KeyNamePair(Integer.parseInt(roleId), roleId));
// Set Client ----
StringBuffer script = new StringBuffer("{\"options\":[");
for (int i = 0; i < clients.length; i++) {
if (i > 0)
script.append(",");
KeyNamePair p = clients[i];
script.append("{\"text\":\"");
// text
script.append(p.getName());
script.append("\",\"value\":\"");
// value
script.append(p.getKey());
script.append("\"}); ");
}
script.append("]}");
/*
// Set Organization ----
if (clients.length > 0)
{
// var A=top.WWindow.document.formName.selectName.options;
script.append("var B=").append(form).append(WLogin.P_ORG).append(".options; ");
// A.length=0; // resets options
script.append("B.length=0; ");
// A[0]=new Option('text','value'); // add new oprtion
KeyNamePair[] orgs = login.getOrgs (clients[0]);
for (int i = 0; i < orgs.length; i++)
{
KeyNamePair p = orgs[i];
script.append("B[").append(i).append("]=new Option('");
script.append(p.getName()); // text
script.append("','");
script.append(p.getKey()); // value
script.append("'); ");
}
script.append("\n");
// Set Warehouse ----
if (orgs.length > 0)
{
// var A=top.WWindow.document.formName.selectName.options;
script.append("var C=").append(form).append(WLogin.P_WAREHOUSE).append(".options; ");
// A.length=0; // resets options
script.append("C.length=0; ");
// A[0]=new Option('text','value'); // add new oprtion
KeyNamePair[] whs = login.getWarehouses (orgs[0]);
if (whs != null)
{
for (int i = 0; i < whs.length; i++)
{
KeyNamePair p = whs[i];
script.append("C[").append(i).append("]=new Option('");
script.append(p.getName()); // text
script.append("','");
script.append(p.getKey()); // value
script.append("'); ");
}
}
} // we have a org
} // we have a client
// add script
body.addElement(new p().addElement(WLogin.P_CLIENT + "="));
body.addElement(new script(script.toString()));
// log.trace(log.l6_Database, "reply_Login2_Role - Script=" + script.toString());
*/
}
Aggregations