use of org.compiere.util.Login in project adempiere by adempiere.
the class WFieldUpdate method reply_Login2_Client.
// reply_Login2_Role
/**
* Login 2nd page Response - Field Client.
* <p>
* fill Org & Warehouse -
* @param body body
* @param wsc context
* @param formName form name
* @param fieldValue value
*/
private static void reply_Login2_Client(body body, MobileSessionCtx wsc, String formName, String fieldValue, String locationValue) {
log.info("Location-Client: " + locationValue);
// Formname
String form = null;
//if (locationValue!=null)
form = locationValue + MobileEnv.TARGET_WINDOW + ".document." + formName + ".";
//else
//form = "top." + WebEnv.TARGET_WINDOW + ".document." + formName + ".";
StringBuffer script = new StringBuffer();
//log.info("form_client->"+form);
// Set Organization ----
// 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 client = new KeyNamePair(Integer.parseInt(fieldValue), fieldValue);
Login login = new Login(wsc.ctx);
KeyNamePair[] orgs = login.getOrgs(client);
for (int i = 0; i < orgs.length; i++) {
KeyNamePair p = orgs[i];
script.append("B[").append(i).append("]=new Option('");
// text
script.append(p.getName());
script.append("','");
// value
script.append(p.getKey());
script.append("'); ");
}
script.append("\n");
// Set Warehouse ----
// 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('");
// text
script.append(p.getName());
script.append("','");
// value
script.append(p.getKey());
script.append("'); ");
}
}
// add script
body.addElement(new p().addElement(WLogin.P_WAREHOUSE + "="));
body.addElement(new script(script.toString()));
// log.trace(log.l6_Database, "Login2-Client - Script=" + script.toString());
}
use of org.compiere.util.Login in project adempiere by adempiere.
the class WFieldUpdate 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 formName, String fieldValue, String locationValue) {
// Formname
String form = null;
log.info("Location-Role: " + locationValue);
//if (locationValue!=null)
form = locationValue + MobileEnv.TARGET_WINDOW + ".document.forms." + formName + ".";
//else
//form = "top." + WebEnv.TARGET_WINDOW + ".document.forms." + formName + ".";
//log.info("form_role->"+form);
Login login = new Login(wsc.ctx);
// Get Data
KeyNamePair[] clients = login.getClients(new KeyNamePair(Integer.parseInt(fieldValue), fieldValue));
// Set Client ----
StringBuffer script = new StringBuffer();
// var A=top.WWindow.document.formName.selectName.options;
script.append("var A=").append(form).append(WLogin.P_CLIENT).append(".options; ");
// A.length=0; // resets options
script.append("A.length=0; ");
for (int i = 0; i < clients.length; i++) {
KeyNamePair p = clients[i];
script.append("A[").append(i).append("]=new Option('");
// text
script.append(p.getName());
script.append("','");
// value
script.append(p.getKey());
script.append("'); ");
}
script.append("\n");
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('");
// text
script.append(p.getName());
script.append("','");
// value
script.append(p.getKey());
script.append("'); ");
}
script.append("\n");
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('");
// text
script.append(p.getName());
script.append("','");
// value
script.append(p.getKey());
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());
}
use of org.compiere.util.Login in project adempiere by adempiere.
the class WFieldUpdate method reply_Login2_Org.
// reply_Login2_Client
/**
* Login 2nd page Response - Field Org.
* <p>
* fill Warehouse
* @param body document body
* @param wsc web session context
* @param formName
* @param fieldValue
*/
private static void reply_Login2_Org(body body, MobileSessionCtx wsc, WWindowStatus ws, String formName, String fieldValue, String locationValue) {
// Formname
String form = null;
log.info("Location-Org: " + locationValue);
//if (locationValue!=null)
form = locationValue + MobileEnv.TARGET_WINDOW + ".document." + formName + ".";
//else
//form = "top." + WebEnv.TARGET_WINDOW + ".document." + formName + ".";
//log.info("form_org->"+form);
StringBuffer script = new StringBuffer();
// Set Warehouse ----
// 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 org = new KeyNamePair(Integer.parseInt(fieldValue), fieldValue);
Login login = new Login(wsc.ctx);
String error = login.validateLogin(org);
if (error != null && error.length() > 0) {
//todo graceful dead
log.severe(error);
ws.mWindow = null;
wsc.ctx = new Properties();
return;
}
KeyNamePair[] whs = login.getWarehouses(org);
if (whs != null) {
for (int i = 0; i < whs.length; i++) {
KeyNamePair p = whs[i];
script.append("C[").append(i).append("]=new Option('");
// text
script.append(p.getName());
script.append("','");
// value
script.append(p.getKey());
script.append("'); ");
}
}
// add script
body.addElement(new p().addElement(WLogin.P_WAREHOUSE + "="));
body.addElement(new script(script.toString()));
// log.trace(log.l6_Database, "Login2-Org - Script=" + script.toString());
}
use of org.compiere.util.Login in project adempiere by adempiere.
the class LoginDynUpdate method reply_Login2_Org.
// reply_Login2_Client
/**
* Login 2nd page Response - Field Org.
* <p>
* fill Warehouse
* @param body document body
* @param wsc web session context
* @param formName
* @param fieldValue
*/
private static void reply_Login2_Org(body body, MobileSessionCtx wsc, WWindowStatus ws, String formName, String fieldValue, String locationValue) {
// Formname
String form = null;
log.info("Location-Org: " + locationValue);
//if (locationValue!=null)
form = locationValue + MobileEnv.TARGET_WINDOW + ".document." + formName + ".";
//else
//form = "top." + WebEnv.TARGET_WINDOW + ".document." + formName + ".";
//log.info("form_org->"+form);
StringBuffer script = new StringBuffer();
// Set Warehouse ----
// 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 org = new KeyNamePair(Integer.parseInt(fieldValue), fieldValue);
Login login = new Login(wsc.ctx);
String error = login.validateLogin(org);
if (error != null && error.length() > 0) {
//todo graceful dead
log.severe(error);
ws.mWindow = null;
wsc.ctx = new Properties();
return;
}
KeyNamePair[] whs = login.getWarehouses(org);
if (whs != null) {
for (int i = 0; i < whs.length; i++) {
KeyNamePair p = whs[i];
script.append("C[").append(i).append("]=new Option('");
// text
script.append(p.getName());
script.append("','");
// value
script.append(p.getKey());
script.append("'); ");
}
}
// add script
body.addElement(new p().addElement(WLogin.P_WAREHOUSE + "="));
body.addElement(new script(script.toString()));
// log.trace(log.l6_Database, "Login2-Org - Script=" + script.toString());
}
use of org.compiere.util.Login in project adempiere by adempiere.
the class LoginDynUpdate method reply_Login2_Client.
// reply_Login2_Role
/**
* Login 2nd page Response - Field Client.
* <p>
* fill Org & Warehouse -
* @param body body
* @param wsc context
* @param formName form name
* @param fieldValue value
*/
private static void reply_Login2_Client(body body, MobileSessionCtx wsc, String formName, String fieldValue, String locationValue) {
log.info("Location-Client: " + locationValue);
// Formname
String form = null;
//if (locationValue!=null)
form = locationValue + MobileEnv.TARGET_WINDOW + ".document." + formName + ".";
//else
//form = "top." + WebEnv.TARGET_WINDOW + ".document." + formName + ".";
StringBuffer script = new StringBuffer();
//log.info("form_client->"+form);
// Set Organization ----
// 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 client = new KeyNamePair(Integer.parseInt(fieldValue), fieldValue);
Login login = new Login(wsc.ctx);
KeyNamePair[] orgs = login.getOrgs(client);
for (int i = 0; i < orgs.length; i++) {
KeyNamePair p = orgs[i];
script.append("B[").append(i).append("]=new Option('");
// text
script.append(p.getName());
script.append("','");
// value
script.append(p.getKey());
script.append("'); ");
}
script.append("\n");
// Set Warehouse ----
// 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('");
// text
script.append(p.getName());
script.append("','");
// value
script.append(p.getKey());
script.append("'); ");
}
}
// add script
body.addElement(new p().addElement(WLogin.P_WAREHOUSE + "="));
body.addElement(new script(script.toString()));
// log.trace(log.l6_Database, "Login2-Client - Script=" + script.toString());
}
Aggregations