details:   https://code.openbravo.com/erp/devel/pi/rev/cf3e984e1fae
changeset: 16715:cf3e984e1fae
user:      Augusto Mauch <augusto.mauch <at> openbravo.com>
date:      Thu May 31 11:28:27 2012 +0200
summary:   Related to issue 20257: Callouts updated to select first contact

Without this change, no contact is set when selecting a business partner. Then, 
when sending an email, no email address is set in the "To" field

diffstat:

 src/org/openbravo/erpCommon/ad_callouts/SE_Invoice_BPartner.java  |  61 
++++++++-
 src/org/openbravo/erpCommon/ad_callouts/SE_Order_BPartner.java    |  17 +-
 src/org/openbravo/erpCommon/ad_callouts/SE_Project_BPartner.java  |  28 +++-
 src/org/openbravo/erpCommon/ad_callouts/SE_Proposal_BPartner.java |  29 +++-
 src/org/openbravo/erpCommon/ad_callouts/SL_InOut_BPartner.java    |  32 ++++-
 5 files changed, 134 insertions(+), 33 deletions(-)

diffs (252 lines):

diff -r 3ee74d6d79b1 -r cf3e984e1fae 
src/org/openbravo/erpCommon/ad_callouts/SE_Invoice_BPartner.java
--- a/src/org/openbravo/erpCommon/ad_callouts/SE_Invoice_BPartner.java  Wed May 
30 18:12:16 2012 +0200
+++ b/src/org/openbravo/erpCommon/ad_callouts/SE_Invoice_BPartner.java  Thu May 
31 11:28:27 2012 +0200
@@ -155,12 +155,14 @@
           resultado.append("new Array(\"" + tdv[i].getField("id") + "\", \""
               + FormatUtilities.replaceJS(tdv[i].getField("name")) + "\", \""
               + (tdv[i].getField("id").equalsIgnoreCase(strLocation) ? "true" 
: "false") + "\")");
-          if (i < tdv.length - 1)
+          if (i < tdv.length - 1) {
             resultado.append(",\n");
+          }
         }
         resultado.append("\n)");
-      } else
+      } else {
         resultado.append("null");
+      }
       resultado.append("\n),");
       resultado.append("new Array(\"inpsalesrepId\", ");
       FieldProvider[] tld = null;
@@ -206,12 +208,29 @@
       resultado.append("new Array(\"inpcBpartnerContactId\", ");
       if (tdv != null && tdv.length > 0) {
         resultado.append("new Array(");
-        for (int i = 0; i < tdv.length; i++) {
-          resultado.append("new Array(\"" + tdv[i].getField("id") + "\", \""
-              + FormatUtilities.replaceJS(tdv[i].getField("name")) + "\", \""
-              + (tdv[i].getField("id").equalsIgnoreCase(strContact) ? "true" : 
"false") + "\")");
-          if (i < tdv.length - 1)
+        if (strContact.isEmpty()) {
+          // If a contactID has not been specified, the first one is selected
+          resultado.append("new Array(\"" + tdv[0].getField("id") + "\", \""
+              + FormatUtilities.replaceJS(tdv[0].getField("name")) + "\", \"" 
+ "true" + "\")");
+          if (tdv.length > 1) {
             resultado.append(",\n");
+          }
+          for (int i = 1; i < tdv.length; i++) {
+            resultado.append("new Array(\"" + tdv[i].getField("id") + "\", \""
+                + FormatUtilities.replaceJS(tdv[i].getField("name")) + "\", 
\"" + "false" + "\")");
+            if (i < tdv.length - 1) {
+              resultado.append(",\n");
+            }
+          }
+        } else {
+          for (int i = 0; i < tdv.length; i++) {
+            resultado.append("new Array(\"" + tdv[i].getField("id") + "\", \""
+                + FormatUtilities.replaceJS(tdv[i].getField("name")) + "\", \""
+                + (tdv[i].getField("id").equalsIgnoreCase(strContact) ? "true" 
: "false") + "\")");
+            if (i < tdv.length - 1) {
+              resultado.append(",\n");
+            }
+          }
         }
         resultado.append("\n)");
       } else
@@ -233,13 +252,31 @@
       resultado.append("new Array(\"inpadUserId\", ");
       if (tdv != null && tdv.length > 0) {
         resultado.append("new Array(");
-        for (int i = 0; i < tdv.length; i++) {
-          resultado.append("new Array(\"" + tdv[i].getField("id") + "\", \""
-              + FormatUtilities.replaceJS(tdv[i].getField("name")) + "\", \""
-              + (tdv[i].getField("id").equalsIgnoreCase(strContact) ? "true" : 
"false") + "\")");
-          if (i < tdv.length - 1)
+
+        if (strContact.isEmpty()) {
+          resultado.append("new Array(\"" + tdv[0].getField("id") + "\", \""
+              + FormatUtilities.replaceJS(tdv[0].getField("name")) + "\", \"" 
+ "true" + "\")");
+          if (tdv.length > 1) {
             resultado.append(",\n");
+          }
+          for (int i = 1; i < tdv.length; i++) {
+            resultado.append("new Array(\"" + tdv[i].getField("id") + "\", \""
+                + FormatUtilities.replaceJS(tdv[i].getField("name")) + "\", 
\"" + "false" + "\")");
+            if (i < tdv.length - 1) {
+              resultado.append(",\n");
+            }
+          }
+        } else {
+          for (int i = 0; i < tdv.length; i++) {
+            resultado.append("new Array(\"" + tdv[i].getField("id") + "\", \""
+                + FormatUtilities.replaceJS(tdv[i].getField("name")) + "\", \""
+                + (tdv[i].getField("id").equalsIgnoreCase(strContact) ? "true" 
: "false") + "\")");
+            if (i < tdv.length - 1) {
+              resultado.append(",\n");
+            }
+          }
         }
+
         resultado.append("\n)");
       } else
         resultado.append("null");
diff -r 3ee74d6d79b1 -r cf3e984e1fae 
src/org/openbravo/erpCommon/ad_callouts/SE_Order_BPartner.java
--- a/src/org/openbravo/erpCommon/ad_callouts/SE_Order_BPartner.java    Wed May 
30 18:12:16 2012 +0200
+++ b/src/org/openbravo/erpCommon/ad_callouts/SE_Order_BPartner.java    Thu May 
31 11:28:27 2012 +0200
@@ -121,7 +121,6 @@
     if (!strLocation.isEmpty()) {
       if (tdv != null && tdv.length > 0) {
         info.addSelect("inpcBpartnerLocationId");
-
         for (int i = 0; i < tdv.length; i++) {
           info.addSelectResult(tdv[i].getField("id"), tdv[i].getField("name"), 
tdv[i]
               .getField("id").equalsIgnoreCase(strLocation));
@@ -324,11 +323,19 @@
     if (tdv != null && tdv.length > 0) {
       info.addSelect("inpadUserId");
 
-      for (int i = 0; i < tdv.length; i++) {
-        info.addSelectResult(tdv[i].getField("id"), tdv[i].getField("name"), 
tdv[i].getField("id")
-            
.equalsIgnoreCase(info.vars.getStringParameter("inpcBpartnerId_CON")));
+      String contactID = info.vars.getStringParameter("inpcBpartnerId_CON");
+      if (contactID.isEmpty()) {
+        // If a contactID has not been specified, the first one is selected
+        info.addSelectResult(tdv[0].getField("id"), tdv[0].getField("name"), 
true);
+        for (int i = 1; i < tdv.length; i++) {
+          info.addSelectResult(tdv[i].getField("id"), tdv[i].getField("name"), 
false);
+        }
+      } else {
+        for (int i = 0; i < tdv.length; i++) {
+          info.addSelectResult(tdv[i].getField("id"), tdv[i].getField("name"), 
tdv[i]
+              
.getField("id").equalsIgnoreCase(info.vars.getStringParameter("inpcBpartnerId_CON")));
+        }
       }
-
       info.endSelect();
 
     } else {
diff -r 3ee74d6d79b1 -r cf3e984e1fae 
src/org/openbravo/erpCommon/ad_callouts/SE_Project_BPartner.java
--- a/src/org/openbravo/erpCommon/ad_callouts/SE_Project_BPartner.java  Wed May 
30 18:12:16 2012 +0200
+++ b/src/org/openbravo/erpCommon/ad_callouts/SE_Project_BPartner.java  Thu May 
31 11:28:27 2012 +0200
@@ -138,13 +138,31 @@
     resultado.append("new Array(\"inpadUserId\", ");
     if (tdv != null && tdv.length > 0) {
       resultado.append("new Array(");
-      for (int i = 0; i < tdv.length; i++) {
-        resultado.append("new Array(\"" + tdv[i].getField("id") + "\", \""
-            + FormatUtilities.replaceJS(tdv[i].getField("name")) + "\", \""
-            + (tdv[i].getField("id").equalsIgnoreCase(strContact) ? "true" : 
"false") + "\")");
-        if (i < tdv.length - 1)
+
+      if (strContact.isEmpty()) {
+        resultado.append("new Array(\"" + tdv[0].getField("id") + "\", \""
+            + FormatUtilities.replaceJS(tdv[0].getField("name")) + "\", \"" + 
"true" + "\")");
+        if (tdv.length > 1) {
           resultado.append(",\n");
+        }
+        for (int i = 1; i < tdv.length; i++) {
+          resultado.append("new Array(\"" + tdv[i].getField("id") + "\", \""
+              + FormatUtilities.replaceJS(tdv[i].getField("name")) + "\", \"" 
+ "false" + "\")");
+          if (i < tdv.length - 1) {
+            resultado.append(",\n");
+          }
+        }
+      } else {
+        for (int i = 0; i < tdv.length; i++) {
+          resultado.append("new Array(\"" + tdv[i].getField("id") + "\", \""
+              + FormatUtilities.replaceJS(tdv[i].getField("name")) + "\", \""
+              + (tdv[i].getField("id").equalsIgnoreCase(strContact) ? "true" : 
"false") + "\")");
+          if (i < tdv.length - 1) {
+            resultado.append(",\n");
+          }
+        }
       }
+
       resultado.append("\n)");
     } else
       resultado.append("null");
diff -r 3ee74d6d79b1 -r cf3e984e1fae 
src/org/openbravo/erpCommon/ad_callouts/SE_Proposal_BPartner.java
--- a/src/org/openbravo/erpCommon/ad_callouts/SE_Proposal_BPartner.java Wed May 
30 18:12:16 2012 +0200
+++ b/src/org/openbravo/erpCommon/ad_callouts/SE_Proposal_BPartner.java Thu May 
31 11:28:27 2012 +0200
@@ -120,13 +120,32 @@
     resultado.append("new Array(\"inpadUserId\", ");
     if (tdv != null && tdv.length > 0) {
       resultado.append("new Array(");
-      for (int i = 0; i < tdv.length; i++) {
-        resultado.append("new Array(\"" + tdv[i].getField("id") + "\", \""
-            + FormatUtilities.replaceJS(tdv[i].getField("name")) + "\", \""
-            + (tdv[i].getField("id").equalsIgnoreCase(strContact) ? "true" : 
"false") + "\")");
-        if (i < tdv.length - 1)
+
+      if (strContact.isEmpty()) {
+        // If a contactID has not been specified, the first one is selected
+        resultado.append("new Array(\"" + tdv[0].getField("id") + "\", \""
+            + FormatUtilities.replaceJS(tdv[0].getField("name")) + "\", \"" + 
"true" + "\")");
+        if (tdv.length > 1) {
           resultado.append(",\n");
+        }
+        for (int i = 1; i < tdv.length; i++) {
+          resultado.append("new Array(\"" + tdv[i].getField("id") + "\", \""
+              + FormatUtilities.replaceJS(tdv[i].getField("name")) + "\", \"" 
+ "false" + "\")");
+          if (i < tdv.length - 1) {
+            resultado.append(",\n");
+          }
+        }
+      } else {
+        for (int i = 0; i < tdv.length; i++) {
+          resultado.append("new Array(\"" + tdv[i].getField("id") + "\", \""
+              + FormatUtilities.replaceJS(tdv[i].getField("name")) + "\", \""
+              + (tdv[i].getField("id").equalsIgnoreCase(strContact) ? "true" : 
"false") + "\")");
+          if (i < tdv.length - 1) {
+            resultado.append(",\n");
+          }
+        }
       }
+
       resultado.append("\n)");
     } else
       resultado.append("null");
diff -r 3ee74d6d79b1 -r cf3e984e1fae 
src/org/openbravo/erpCommon/ad_callouts/SL_InOut_BPartner.java
--- a/src/org/openbravo/erpCommon/ad_callouts/SL_InOut_BPartner.java    Wed May 
30 18:12:16 2012 +0200
+++ b/src/org/openbravo/erpCommon/ad_callouts/SL_InOut_BPartner.java    Thu May 
31 11:28:27 2012 +0200
@@ -159,14 +159,34 @@
     resultado.append("new Array(\"inpadUserId\", ");
     if (tdv != null && tdv.length > 0) {
       resultado.append("new Array(");
-      for (int i = 0; i < tdv.length; i++) {
-        resultado.append("new Array(\"" + tdv[i].getField("id") + "\", \""
-            + 
FormatUtilities.replaceJS(Replace.replace(tdv[i].getField("name"), "\"", 
"\\\""))
-            + "\", \"" + (tdv[i].getField("id").equalsIgnoreCase(strContact) ? 
"true" : "false")
-            + "\")");
-        if (i < tdv.length - 1)
+
+      if (strContact.isEmpty()) {
+        resultado.append("new Array(\"" + tdv[0].getField("id") + "\", \""
+            + 
FormatUtilities.replaceJS(Replace.replace(tdv[0].getField("name"), "\"", 
"\\\""))
+            + "\", \"" + "true" + "\")");
+        if (tdv.length > 1) {
           resultado.append(",\n");
+        }
+        for (int i = 1; i < tdv.length; i++) {
+          resultado.append("new Array(\"" + tdv[i].getField("id") + "\", \""
+              + 
FormatUtilities.replaceJS(Replace.replace(tdv[i].getField("name"), "\"", 
"\\\""))
+              + "\", \"" + "false" + "\")");
+          if (i < tdv.length - 1) {
+            resultado.append(",\n");
+          }
+        }
+      } else {
+        for (int i = 0; i < tdv.length; i++) {
+          resultado.append("new Array(\"" + tdv[i].getField("id") + "\", \""
+              + 
FormatUtilities.replaceJS(Replace.replace(tdv[i].getField("name"), "\"", 
"\\\""))
+              + "\", \"" + (tdv[i].getField("id").equalsIgnoreCase(strContact) 
? "true" : "false")
+              + "\")");
+          if (i < tdv.length - 1) {
+            resultado.append(",\n");
+          }
+        }
       }
+
       resultado.append("\n)");
     } else
       resultado.append("null");

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to