Package com.sourcetap.sfa.util

Examples of com.sourcetap.sfa.util.UserInfo


      out.write("<!-- [oldFunctions.jsp] End -->\r\n\r\n");
      out.write("\r\n");
      out.write("<!-- [oldDeclarations.jsp] Start -->\r\n\r\n");
GenericValue userLogin = (GenericValue)session.getAttribute("_USER_LOGIN_");
      out.write("\r\n");
UserInfo userInfo  = (UserInfo) session.getAttribute("userInfo");
      out.write("\r\n\r\n");
  String partyId = "";
  if (userLogin != null )
       partyId = userLogin.getString("partyId");
View Full Code Here


String action = request.getParameter("action");
if ( (action == null ) || ( action.length() < 1) )
{
   Preference pref = Preference.getInstance(delegator);
   UserInfo userInfo  = (UserInfo) session.getAttribute("userInfo");
   action = pref.getPreference( userInfo.getPartyId(), userInfo.getAccountId(), "SCREEN_ACTION", UIScreenSection.ACTION_SHOW_INSERT);
}


      out.write("\r\n\r\n");
View Full Code Here

      out.write("<!-- [oldFunctions.jsp] End -->\r\n\r\n");
      out.write("\r\n");
      out.write("<!-- [oldDeclarations.jsp] Start -->\r\n\r\n");
GenericValue userLogin = (GenericValue)session.getAttribute("_USER_LOGIN_");
      out.write("\r\n");
UserInfo userInfo  = (UserInfo) session.getAttribute("userInfo");
      out.write("\r\n\r\n");
  String partyId = "";
  if (userLogin != null )
       partyId = userLogin.getString("partyId");
View Full Code Here

      out.write("<!-- [oldFunctions.jsp] End -->\r\n\r\n");
      out.write("\r\n");
      out.write("<!-- [oldDeclarations.jsp] Start -->\r\n\r\n");
GenericValue userLogin = (GenericValue)session.getAttribute("_USER_LOGIN_");
      out.write("\r\n");
UserInfo userInfo  = (UserInfo) session.getAttribute("userInfo");
      out.write("\r\n\r\n");
  String partyId = "";
  if (userLogin != null )
       partyId = userLogin.getString("partyId");

      out.write("\r\n\r\n");

   DecimalFormat decimalFormat = new DecimalFormat("#,###.##");
   SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM/dd/yyyy");
   SimpleDateFormat simpleTimeFormat = new SimpleDateFormat("K:mm a");

      out.write("\r\n\r\n");
String controlPath=(String)request.getAttribute("_CONTROL_PATH_");
      out.write("\r\n");
String contextRoot=(String)request.getAttribute("_CONTEXT_ROOT_");
      out.write("\r\n\r\n");
String pageName = UtilFormatOut.checkNull((String)pageContext.getAttribute("PageName"));
      out.write("\r\n\r\n");
String companyName = UtilProperties.getPropertyValue(contextRoot + "/WEB-INF/sfa.properties", "company.name");
      out.write("\r\n");
String companySubtitle = UtilProperties.getPropertyValue(contextRoot + "/WEB-INF/sfa.properties", "company.subtitle");
      out.write("\r\n");
String headerImageUrl = UtilProperties.getPropertyValue(contextRoot + "/WEB-INF/sfa.properties", "header.image.url");
      out.write("\r\n\r\n");
String headerBoxBorderColor = UtilProperties.getPropertyValue(contextRoot + "/WEB-INF/sfa.properties", "header.box.border.color", "black");
      out.write("\r\n");
String headerBoxBorderWidth = UtilProperties.getPropertyValue(contextRoot + "/WEB-INF/sfa.properties", "header.box.border.width", "1");
      out.write("\r\n");
String headerBoxTopColor = UtilProperties.getPropertyValue(contextRoot + "/WEB-INF/sfa.properties", "header.box.top.color", "#336699");
      out.write("\r\n");
String headerBoxBottomColor = UtilProperties.getPropertyValue(contextRoot + "/WEB-INF/sfa.properties", "header.box.bottom.color", "#cccc99");
      out.write("\r\n");
String headerBoxBottomColorAlt = UtilProperties.getPropertyValue(contextRoot + "/WEB-INF/sfa.properties", "header.box.bottom.alt.color", "#eeeecc");
      out.write("\r\n");
String headerBoxTopPadding = UtilProperties.getPropertyValue(contextRoot + "/WEB-INF/sfa.properties", "header.box.top.padding", "4");
      out.write("\r\n");
String headerBoxBottomPadding = UtilProperties.getPropertyValue(contextRoot + "/WEB-INF/sfa.properties", "header.box.bottom.padding", "2");
      out.write("\r\n\r\n");
String boxBorderColor = UtilProperties.getPropertyValue(contextRoot + "/WEB-INF/sfa.properties", "box.border.color", "black");
      out.write("\r\n");
String boxBorderWidth = UtilProperties.getPropertyValue(contextRoot + "/WEB-INF/sfa.properties", "box.border.width", "1");
      out.write("\r\n");
String boxTopColor = UtilProperties.getPropertyValue(contextRoot + "/WEB-INF/sfa.properties", "box.top.color", "#336699");
      out.write("\r\n");
String boxBottomColor = UtilProperties.getPropertyValue(contextRoot + "/WEB-INF/sfa.properties", "box.bottom.color", "white");
      out.write("\r\n");
String boxBottomColorAlt = UtilProperties.getPropertyValue(contextRoot + "/WEB-INF/sfa.properties", "box.bottom.alt.color", "white");
      out.write("\r\n");
String boxTopPadding = UtilProperties.getPropertyValue(contextRoot + "/WEB-INF/sfa.properties", "box.top.padding", "4");
      out.write("\r\n");
String boxBottomPadding = UtilProperties.getPropertyValue(contextRoot + "/WEB-INF/sfa.properties", "box.bottom.padding", "4");
      out.write("\r\n");
String userStyleSheet = "/sfa/includes/maincss.css";
      out.write("\r\n");
String alphabet[]={"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "*"};
      out.write("\r\n\r\n");
      out.write("<!-- [oldDeclarations.jsp] End -->\r\n\r\n");
      out.write("\r\n\r\n");
      out.write("<HTML>\r\n");
      out.write("<HEAD>\r\n\r\n");

String clientRequest = (String)session.getAttribute("_CLIENT_REQUEST_");
//out.write("Client request: " + clientRequest + "<BR>");
String hostName = "";
if (clientRequest!=null && clientRequest.indexOf("//") > 0) {
int startPos = clientRequest.indexOf("//") + 2;
int endPos = clientRequest.indexOf(":", startPos);
if ( endPos < startPos )
   endPos = clientRequest.indexOf("/", startPos);
if ( endPos < startPos )
   hostName = clientRequest.substring(startPos);
else
    hostName = clientRequest.substring(startPos, endPos);
} else {
hostName = "";
}
//out.write("Host name: " + hostName + "<BR>");

      out.write("\r\n\r\n");
      out.write("<title>");
      out.print(hostName);
      out.write(" - Sales Force Automation - ");
      out.print(companyName);
      out.write("</title>\r\n\r\n");
      out.write("\r\n");
      out.write("<!-- [userStyle.jsp] Start -->\r\n\r\n");

//------------ Get the style sheet
String styleSheetId = null;

ModelEntity entityStyleUser = delegator.getModelEntity("UiUserTemplate");
HashMap hashMapStyleUser = new HashMap();
if ( userLogin != null ) {
  String ulogin = userLogin.getString("userLoginId");
  hashMapStyleUser.put("userLoginId", ulogin);
} else {
  hashMapStyleUser.put("userLoginId", "Default");
}
GenericPK stylePk = new GenericPK(entityStyleUser, hashMapStyleUser);
GenericValue userTemplate = delegator.findByPrimaryKey(stylePk);
if ( userTemplate != null ) {
  styleSheetId = userTemplate.getString("styleSheetId");
}

if (styleSheetId == null){
  hashMapStyleUser.put("userLoginId", "Default");
  stylePk = new GenericPK(entityStyleUser, hashMapStyleUser);
  userTemplate = delegator.findByPrimaryKey(stylePk);
  if ( userTemplate != null ) {
    styleSheetId = userTemplate.getString("styleSheetId");
  }
}

if (styleSheetId != null){
  ModelEntity entityStyle = delegator.getModelEntity("UiStyleTemplate");
  HashMap hashMapStyle = new HashMap();
  hashMapStyle.put("styleSheetId", styleSheetId);
  stylePk = new GenericPK(entityStyle, hashMapStyle);
  GenericValue styleTemplate = delegator.findByPrimaryKey(stylePk);
  userStyleSheet = styleTemplate.getString("styleSheetLoc");

  if ( userStyleSheet == null ){
    userStyleSheet = "/sfa/includes/maincss.css";
  }
}


      out.write("\r\n");
      out.write("<link rel=\"stylesheet\" href=\"");
      out.print(userStyleSheet);
      out.write("\" type=\"text/css\">\r\n\r\n");
      out.write("<!-- [userStyle.jsp] End -->\r\n\r\n");
      out.write("\r\n");
      out.write("<LINK rel=\"stylesheet\" type=\"text/css\" href=\"/sfa/css/gridstyles.css\">\r\n");
      out.write("<script language=\"JavaScript\" >\r\n\r\n  function sendDropDown(elementName, idName, fieldName, findClass, paramName, paramValue, frm, action)\r\n  {\r\n        var sUrl = '");
      if (_jspx_meth_ofbiz_url_0(pageContext))
        return;
      out.write("?findMode=filter&fieldName=' +\r\n\t\t\tfieldName + '&idName=' + idName + '&param_' + paramName + '=' + paramValue +\r\n\t\t\t'&formName=' + frm.name + '&elementName=' + elementName + '&findClass=' + findClass + '&action=' + action;\r\n        document.anchors('searchA').href=sUrl;\r\n        document.anchors('searchA').click();\r\n  }\r\n\r\n\r\n  function sendData(ele, frm, action){\r\n    if(ele.tagName != 'SELECT'){\r\n      if(ele.value.length > 0){\r\n        entity = ele.getAttribute(\"entityName\");\r\n        field = ele.getAttribute(\"fieldName\");\r\n        idName = ele.getAttribute(\"idName\");\r\n        findClass = ele.getAttribute(\"findClass\");\r\n        findValue = ele.value;\r\n        elementName = ele.name;\r\n        var sUrl = '");
      if (_jspx_meth_ofbiz_url_1(pageContext))
        return;
      out.write("?entityName=' + entity + '&fieldName=' +\r\n\t\t\tfield + '&idName=' + idName + '&findByLikeValue=' + findValue + '&formName=' + frm.name +\r\n\t\t\t'&elementName=' + elementName + '&findClass=' + findClass + '&action=' + action;\r\n        document.anchors('searchA').href=sUrl;\r\n        document.anchors('searchA').click();\r\n      } else {\r\n        //alert('Enter search criteria to find a value.');\r\n        //frm.item(ele.name).value = 'Enter search criteria.';\r\n      }\r\n    }\r\n  }\r\n\r\n  function updateForm(){\r\n    var innDoc = document.frames('searchIFrame').document;\r\n    var innHtml = innDoc.body.innerHTML;\r\n    if(innHtml.length > 0){\r\n      var sDiv = innDoc.all('searchResultDiv');\r\n      if(sDiv != null){\r\n        var formName = sDiv.getAttribute(\"formName\");\r\n        var fieldName = sDiv.getAttribute(\"fieldName\");\r\n        var elementName = sDiv.getAttribute(\"elementName\");\r\n        var findClass = sDiv.getAttribute(\"findClass\");\r\n        var findMode = sDiv.getAttribute(\"findMode\");\r\n        var showMultiple = sDiv.getAttribute(\"showMultiple\");\r\n");
      out.write("        var nde = innDoc.all(elementName);\r\n        var existingNode = document.all(elementName);\r\n        if(nde != null){\r\n          var frm = document.forms(formName);\r\n          if(nde.tagName == 'SELECT'){\r\n            var opts = nde.children.tags('OPTION');\r\n            if ( findMode == 'filter')\r\n            {\r\n\t\t\t\tvar oldOpts = existingNode.children.tags('OPTION');\r\n//\t\t\t\talert('oldOpts.length = ' + oldOpts.length);\r\n//\t\t\t\talert('opts.length = ' + opts.length);\r\n\t\t\t\tvar numOpt = existingNode.options.length;\r\n//\t\t\t\talert('numOpt = ' + numOpt);\r\n\t\t\t\tfor (var i=0; i");
      out.write("<numOpt;i++)\r\n\t\t\t\t\texistingNode.options.remove(numOpt - 1 - i);\r\n\t\t\t\tfor (var i=0; i");
      out.write("<opts.length;i++)\r\n\t\t\t\t{\r\n\t\t\t\t\tvar opt = document.createElement(\"option\");\r\n\t\t\t\t\topt.setAttribute(\"value\", opts(i).value);\r\n\t\t\t\t\topt.innerText = opts(i).innerText;\r\n\t\t\t\t\texistingNode.appendChild(opt);\r\n\t\t\t\t}\r\n            }\r\n            else if(opts.length");
      out.write("<=0){\r\n              //alert('No results were found.  Please try another search.');\r\n              existingNode.focus();\r\n            } else {\r\n              var ele = document.createElement(nde.tagName);\r\n              ele.id = nde.name;\r\n              ele.name = nde.name;\r\n              ele.setAttribute(\"className\", existingNode.getAttribute(\"className\"));\r\n\t\t\t  ele.setAttribute(\"entityName\", sDiv.getAttribute(\"entityName\"));\r\n              ele.setAttribute(\"fieldName\", sDiv.getAttribute(\"fieldName\"));\r\n              ele.setAttribute(\"elementName\", sDiv.getAttribute(\"elementName\"));\r\n              ele.setAttribute(\"idName\",  sDiv.getAttribute(\"idName\"));\r\n              ele.setAttribute(\"findClass\",  sDiv.getAttribute(\"findClass\"));\r\n              if (showMultiple == \"true\") ele.multiple = true;\r\n              ele.tabIndex = existingNode.tabIndex;\r\n              ele.attachEvent(\"onchange\", searchAgain);\r\n              for(var i=0;i");
      out.write("<opts.length;i++){\r\n                var opt = document.createElement(\"option\");\r\n                opt.setAttribute(\"value\", opts(i).value);\r\n                opt.innerText = opts(i).innerText;\r\n                ele.appendChild(opt);\r\n              }\r\n              var opt = document.createElement(\"option\");\r\n              opt.setAttribute(\"value\", \"search again\");\r\n              opt.innerText = \"Search again...\";\r\n              ele.appendChild(opt);\r\n              var sRepNde = elementName + 'Holder';\r\n              var repNde = document.all(sRepNde);\r\n              repNde.replaceChild(ele, existingNode);\r\n              ele.focus();\r\n\t      ele.fireEvent(\"onchange\");\r\n            }\r\n          }\r\n        }\r\n      }\r\n    }\r\n  }\r\n\r\n  function searchAgain(sel, frm){\r\n    if(sel.tagName == 'SELECT'){\r\n      var fieldName = sel.getAttribute('fieldName');\r\n      var findClass = sel.getAttribute('findClass');\r\n      var elementName = sel.name;\r\n      var formName = frm.name;\r\n      var existingNode = document.all(elementName);\r\n");
      out.write("      if(sel.value == 'search again'){\r\n        var ele = document.createElement(\"INPUT\");\r\n        ele.id = sel.name;\r\n        ele.name = sel.name;\r\n        ele.type = \"TEXT\";\r\n        ele.setAttribute(\"className\", existingNode.getAttribute(\"className\"));\r\n        ele.setAttribute(\"entityName\", sel.getAttribute(\"entityName\"));\r\n        ele.setAttribute(\"fieldName\", fieldName);\r\n        ele.setAttribute(\"elementName\", elementName);\r\n        ele.setAttribute(\"idName\",  sel.getAttribute(\"idName\"));\r\n        ele.setAttribute(\"findClass\",  findClass);\r\n        ele.tabIndex = sel.tabIndex;\r\n        var sRepNde = elementName + 'Holder';\r\n        var repNde = document.all(sRepNde);\r\n        repNde.replaceChild(ele, existingNode);\r\n        ele.focus();\r\n      }\r\n    }\r\n  }\r\n\r\n  // currently only used by accountPopup to force activity_accountId to be a select field\r\n  function forceSearchAgain(sel, frm){\r\n    if(sel.tagName == 'SELECT'){\r\n      var fieldName = sel.getAttribute('fieldName');\r\n      var findClass = sel.getAttribute('findClass');\r\n");
      out.write("      var elementName = sel.name;\r\n      var formName = frm.name;\r\n      var existingNode = document.all(elementName);\r\n\t  var ele = document.createElement(\"INPUT\");\r\n\t  ele.id = sel.name;\r\n\t  ele.name = sel.name;\r\n\t  ele.type = \"TEXT\";\r\n\t  ele.setAttribute(\"className\", existingNode.getAttribute(\"className\"));\r\n\t  ele.setAttribute(\"entityName\", sel.getAttribute(\"entityName\"));\r\n\t  ele.setAttribute(\"fieldName\", fieldName);\r\n\t  ele.setAttribute(\"elementName\", elementName);\r\n\t  ele.setAttribute(\"idName\",  sel.getAttribute(\"idName\"));\r\n\t  ele.setAttribute(\"findClass\",  findClass);\r\n\t  ele.tabIndex = sel.tabIndex;\r\n\t  var sRepNde = elementName + 'Holder';\r\n\t  var repNde = document.all(sRepNde);\r\n\t  repNde.replaceChild(ele, existingNode);\r\n    }\r\n  }\r\n\r\nvar currentCol = 0;\r\nvar previousCol = -1;\r\nvar reverse = false;\r\n\r\n  function CompareAlpha(a, b) {\r\n    if (a[currentCol] ");
      out.write("< b[currentCol]) { return -1; }\r\n    if (a[currentCol] > b[currentCol]) { return 1; }\r\n    return 0;\r\n  }\r\n\r\n  function CompareAlphaIgnore(a, b) {\r\n    strA = a[currentCol].toLowerCase();\r\n    strB = b[currentCol].toLowerCase();\r\n    if (strA ");
      out.write("< strB) { return -1;\r\n    } else {\r\n      if (strA > strB) { return 1;\r\n      } else { return 0;\r\n      }\r\n    }\r\n  }\r\n\r\n  function CompareDate(a, b) {\r\n    datA = new Date(a[currentCol]);\r\n    datB = new Date(b[currentCol]);\r\n    if (datA ");
      out.write("< datB) { return -1;\r\n    } else {\r\n      if (datA > datB) { return 1;\r\n      } else { return 0;\r\n      }\r\n    }\r\n  }\r\n\r\n  function CompareDateEuro(a, b) {\r\n    strA = a[currentCol].split(\".\");\r\n    strB = b[currentCol].split(\".\");\r\n    datA = new Date(strA[2], strA[1], strA[0]);\r\n    datB = new Date(strB[2], strB[1], strB[0]);\r\n    if (datA ");
      out.write("< datB) { return -1;\r\n    } else {\r\n      if (datA > datB) { return 1;\r\n      } else { return 0;\r\n      }\r\n    }\r\n  }\r\n\r\n  function CompareNumeric(a, b) {\r\n    numA = a[currentCol];\r\n    numB = b[currentCol];\r\n    if (isNaN(numA)) { return 0;\r\n    } else {\r\n      if (isNaN(numB)) { return 0;\r\n      } else { return numA - numB;\r\n      }\r\n    }\r\n  }\r\n\r\nfunction TableSort(myTable, myCol, myType) {\r\n\r\n  var mySource = document.all(myTable);\r\n  var myRows = mySource.rows.length;\r\n  var myCols = mySource.rows(0).cells.length;\r\n  currentCol = myCol\r\n\r\n  var theadrow = mySource.parentElement.tHead;\r\n  var imgcol= theadrow.all('srtImg');\r\n  for(var x = 0; x ");
      out.write("< imgcol.length; x++){\r\n    imgcol[x].src = \"dude07232001blank.gif\";\r\n    imgcol[x].alt = \"sort\";\r\n  }\r\n\r\n  if(previousCol == myCol){\r\n    if(reverse == false){\r\n      imgcol[myCol-1].src = \"dude07232001down.gif\";\r\n      reverse = true;\r\n    } else {\r\n      imgcol[myCol-1].src = \"dude07232001up.gif\";\r\n      reverse = false;\r\n    }\r\n  } else {\r\n    reverse = false;\r\n    imgcol[myCol-1].src = \"dude07232001up.gif\";\r\n  }\r\n\r\n  myArray = new Array(myRows)\r\n  for (i=0; i ");
      out.write("< myRows; i++) {\r\n    myArray[i] = new Array(myCols)\r\n    for (j=0; j ");
      out.write("< myCols; j++) {\r\n      myArray[i][j] = document.all(myTable).rows(i).cells(j).innerHTML;\r\n    }\r\n  }\r\n\r\n  if (myCol == previousCol) {\r\n    myArray.reverse();\r\n  } else {\r\n    switch (myType) {\r\n      case \"a\":\r\n        myArray.sort(CompareAlpha);\r\n        break;\r\n      case \"ai\":\r\n        myArray.sort(CompareAlphaIgnore);\r\n        break;\r\n      case \"d\":\r\n        myArray.sort(CompareDate);\r\n        break;\r\n      case \"de\":\r\n        myArray.sort(CompareDateEuro);\r\n        break;\r\n      case \"n\":\r\n        myArray.sort(CompareNumeric);\r\n        break;\r\n      default:\r\n        myArray.sort();\r\n    }\r\n  }\r\n\r\n\r\n  // Re-write the table contents\r\n  for (i=0; i ");
      out.write("< myRows; i++) {\r\n    for (j=0; j ");
      out.write("< myCols; j++) {\r\n      mySource.rows(i).cells(j).innerHTML = myArray[i][j];\r\n    }\r\n  }\r\n\r\n  previousCol = myCol;\r\n  highlightSelectedRow();\r\n  return 0;\r\n\r\n}\r\n\r\n  function fixSize() {\r\n      // The body represents the outer-most frameset for frameset documents.\r\n      if ( parent.name == \"content\" )\r\n      {\r\n\t      maxH = parent.document.body.clientHeight - 150;\r\n\t      topH = document.body.scrollHeight + 10;\r\n\t      if ( topH > maxH )\r\n\t      \ttopH = maxH;\r\n\t      \t\r\n\t      parent.document.body.rows = topH + \", *\"\r\n\t      //window.frames.headerFrame.document.body.rows = window.frames.headerFrame.document.body.scrollHeight + \", *\" \r\n\t      // Walk into the header frame and get the scrollHeight - \r\n\t      // this represents the height of the contents in pixels. \r\n\t  }\r\n  }\r\n");
      out.write("</script>\r\n\r\n\r\n");
      out.write("\r\n\r\n");
      out.write("</HEAD>\r\n\r\n");
      out.write("<BASE TARGET=\"content\">\r\n");
      out.write("<!--");
      out.write("<BODY CLASS=\"bodyform\" onbeforeunload=\"verifyClose()\">-->\r\n");
      out.write("<BODY CLASS=\"bodyform\"\">\r\n\r\n");
      out.write("\r\n");
      out.write("<!-- onBeforeUnload.jsp - Start -->\r\n\r\n");
      out.write("<SCRIPT LANGUAGE=\"JScript\" TYPE=\"text/javascript\" FOR=window EVENT=onbeforeunload>\r\n return doOnBeforeUnload();\r\n");
      out.write("</SCRIPT>\r\n\r\n");
      out.write("<SCRIPT LANGUAGE=\"JScript\" TYPE=\"text/javascript\">\r\n\r\n // Create variable we can change to prevent the check from being done.\r\n var checkForChanges = true;\r\n \r\n function doOnBeforeUnload() {\r\n  // This script fires when anything is about to cause the current page to be unloaded.\r\n  // If any unsaved changes have been made, this script returns a non-empty string, which\r\n  // causes a response window to warn the user that changes will be lost, and to allow\r\n  // them to cancel.\r\n \r\n  // In free form, tabular, and select screen sections built by the UI builder,\r\n  // the preSubmit method fired by the onSubmit event of the form removes this script from\r\n  // the onBeforeUnload event, which prevents this check from happening if the Save button\r\n  // was just clicked.\r\n \r\n // alert(\"event.fromElement: \" + event.fromElement);\r\n \r\n  // See if the checkForChanges flag has been cleared. If so, just allow the\r\n  // body unload to continue.\r\n  if (!checkForChanges) return;\r\n \r\n  // Look at all forms on the page to see if any of them have any changes.\r\n");
      out.write("  var vFormC = document.forms;\r\n  for (var vFormNbr = 0; vFormNbr ");
      out.write("< vFormC.length; vFormNbr++) {\r\n   //alert(\"[verifyClose] Window name: \" + window.name);\r\n   //alert(\"[verifyClose] Checking form #\" + vFormNbr);\r\n   var vFormObj = vFormC.item(vFormNbr);\r\n   //alert(\"[verifyClose] Form name is \" + vFormObj.name);\r\n \r\n   // Check the action.  If it's query or view mode, don't bother checking this form.\r\n   var vActionObj = vFormObj.elements.item(\"action\");\r\n   if (vActionObj != null) {\r\n    var vAction = vActionObj.value;\r\n    if (vAction!=null) {\r\n     //alert(\"Action: \" + vAction);\r\n     if (vAction==\"");
      out.print(UIScreenSection.ACTION_INSERT);
      out.write("\" ||\r\n         vAction==\"");
      out.print(UIScreenSection.ACTION_UPDATE);
      out.write("\" ||\r\n         vAction==\"");
      out.print(UIScreenSection.ACTION_UPDATE_SELECT);
      out.write("\") {\r\n \r\n      // This is an updateable form in an updateable mode. Check for changes.\r\n \r\n      // Look through all the objects in the form to see if there are any unsaved changes.\r\n      var vElemC = vFormObj.elements;\r\n      for (var vElemNbr = 0; vElemNbr ");
      out.write("< vElemC.length; vElemNbr++) {\r\n       var vElemObj = vElemC.item(vElemNbr);\r\n \r\n       // Find out if this is the \"add\" or \"delete\" select object that appears on a \"select\" type screen section.\r\n       //alert(\"[window.onbeforeunload] Object name: \" + vElemObj.name);\r\n       if (vElemObj.name.indexOf(\"DBSel\")>=0) {\r\n        // This is the add or delete select object.  See if there are any items in it.  If so, it means\r\n        // the user has made changes.\r\n        if (vElemObj.length > 0) {\r\n         // Changes have been made.  Trigger the response window.\r\n         return \"IF YOU CLICK OK, YOUR CHANGES WILL BE LOST.\";\r\n        } else {\r\n         // No changes in this add or delete select object.\r\n        }\r\n       } else {\r\n        // Object is not the add or delete select object.\");\r\n        // See if this element is an original value field.\r\n        var vOrigPrefix = \"");
      out.print(UIWebUtility.HTML_NAME_PREFIX_ORIGINAL);
      out.write("\";\r\n        if (vElemObj.name.indexOf(vOrigPrefix)==0) {\r\n         // This is an original value field.  Compare its value to the current value field.\r\n         var vOrigElemObj = vElemObj;\r\n         var vOrigElemName = vOrigElemObj.name;\r\n         var vCurElemName = vOrigElemName.substring(vOrigPrefix.length, vOrigElemName.length);\r\n         var vCurElemObj = vElemC.item(vCurElemName);\r\n         var vCurElemTagName = vCurElemObj.tagName;\r\n         var vCurElemType = vCurElemObj.type;\r\n         if (vCurElemObj!=null) {\r\n          // Got the current field. Compare the values.\r\n          var vCurValue;\r\n          if (vCurElemTagName==\"INPUT\" && vCurElemType==\"checkbox\") {\r\n           // This is a check box.  Use special processing to get current value.\r\n           vCurValue = vCurElemObj.checked ? \"Y\" : \"N\";\r\n          } else {\r\n           // Not a check box.\r\n           vCurValue = vCurElemObj.value;\r\n          }\r\n          var vOrigValue = vOrigElemObj.value;\r\n          if (vCurValue != vOrigValue) {\r\n           // This field was changed.  Trigger the response window.\r\n");
      out.write("    //       alert('Field ' + vCurElemName + ' changed.');\r\n    //       alert('Original Value: ' + vOrigValue);\r\n    //       alert('Current Value: ' + vCurValue);\r\n           return \"IF YOU CLICK OK, YOUR CHANGES WILL BE LOST.\";\r\n          }\r\n         }\r\n        }\r\n       }\r\n      }\r\n     }\r\n    }\r\n   }\r\n  }\r\n }\r\n");
      out.write("</SCRIPT>\r\n\r\n");
      out.write("<!-- onBeforeUnload.jsp - End -->\r\n\r\n\r\n");
      out.write("\r\n\r\n");
      out.write("<script>\r\n// Title: Timestamp picker\r\n// Description: See the demo at url\r\n// URL: http://us.geocities.com/tspicker/\r\n// Script featured on: http://javascriptkit.com/script/script2/timestamp.shtml\r\n// Version: 1.0\r\n// Date: 12-05-2001 (mm-dd-yyyy)\r\n// Author: Denis Gritcyuk ");
      out.write("<denis@softcomplex.com>; ");
      out.write("<tspicker@yahoo.com>\r\n// Notes: Permission given to use this script in any kind of applications if\r\n//    header lines are left unchanged. Feel free to contact the author\r\n//    for feature requests and/or donations\r\n\r\nfunction setCalendarHasFocus(aFormObj, aHasFocus) {\r\n\t// Set hidden variable to show that a popup calendar is about to\r\n\t// be displayed.  This variable will be tested in the onBeforeUnload\r\n\t// handling to avoid popping up a confimation prompt.\r\n\talert(\"setCalendarHasFocus start - \" + aHasFocus);\r\n\tvar vCalendarHasFocusObj = aFormObj.elements.item(\"calendarHasFocus\");\r\n\tif (vCalendarHasFocusObj == null) {\r\n\t\t//alert(\"Did not find calendarHasFocus hidden field\");\r\n\t} else {\r\n\t\t//alert(\"Found calendarHasFocus hidden field\");\r\n\t\tif (aHasFocus) {\r\n\t\t\t//alert(\"Setting calendarHasFocus to true\");\r\n\t\t\tvCalendarHasFocusObj.value = \"true\";\r\n\t\t} else {\r\n\t\t\t//alert(\"Setting calendarHasFocus to false\");\r\n\t\t\tvCalendarHasFocusObj.value = \"false\";\r\n\t\t}\r\n\t}\r\n\treturn false;\r\n}\r\n\r\nfunction show_calendar(str_target, str_datetime, isDateTime) {\r\n");
      out.write("//\talert(\"show_calendar start\");\r\n\tvar arr_months = [\"January\", \"February\", \"March\", \"April\", \"May\", \"June\",\r\n\t\t\"July\", \"August\", \"September\", \"October\", \"November\", \"December\"];\r\n\tvar week_days = [\"Su\", \"Mo\", \"Tu\", \"We\", \"Th\", \"Fr\", \"Sa\"];\r\n\tvar n_weekstart = 1; // day week starts from (normally 0 or 1)\r\n\r\n\tvar dt_datetime = (str_datetime == null || str_datetime ==\"\" ?  new Date() :  str2datetime(str_datetime) );\r\n\tvar dt_prev_month = new Date(dt_datetime);\r\n\tdt_prev_month.setMonth(dt_datetime.getMonth()-1);\r\n\tvar dt_next_month = new Date(dt_datetime);\r\n\tdt_next_month.setMonth(dt_datetime.getMonth()+1);\r\n\tvar dt_firstday = new Date(dt_datetime);\r\n\tdt_firstday.setDate(1);\r\n\tdt_firstday.setDate(1-(7+dt_firstday.getDay()-n_weekstart)%7);\r\n\tvar dt_lastday = new Date(dt_next_month);\r\n\tdt_lastday.setDate(0);\r\n\t\r\n\t// html generation (feel free to tune it for your particular application)\r\n\t// print calendar header\r\n\tvar str_buffer = new String (\r\n\t\t\"");
      out.write("<html>\\n\"+\r\n\t\t\" ");
      out.write("<head>\\n\"+\r\n\t\t\"  ");
      out.write("<title>Calendar");
      out.write("</title>\\n\"+\r\n\t\t\" ");
      out.write("</head>\\n\"+\r\n\t\t\" ");
      out.write("<body bgcolor=\\\"White\\\">\\n\"+\r\n\t\t\"  ");
      out.write("<table class=\\\"clsOTable\\\" cellspacing=\\\"0\\\" border=\\\"0\\\" width=\\\"100%\\\">\\n\" +\r\n\t\t\"   ");
      out.write("<tr>\\n\" +\r\n\t\t\"    ");
      out.write("<td bgcolor=\\\"#4682B4\\\">\\n\" +\r\n\t\t\"     ");
      out.write("<table cellspacing=\\\"1\\\" cellpadding=\\\"3\\\" border=\\\"0\\\" width=\\\"100%\\\">\\n\" +\r\n\t\t\"      ");
      out.write("<tr>\\n\" +\r\n\t\t\"       ");
      out.write("<td bgcolor=\\\"#4682B4\\\">\\n\" +\r\n\t\t\"        ");
      out.write("<a href=\\\"javascript:window.opener.show_calendar('\"+\r\n\t\t           str_target + \"', '\" + dt2dtstr(dt_prev_month)+\"'+' ' +document.cal.time.value);\\\">\" +\r\n\t\t\"         ");
      out.write("<img src=\\\"/sfaimages/prev.gif\\\" width=\\\"16\\\" height=\\\"16\\\" border=\\\"0\\\"\" +\r\n\t\t\"           alt=\\\"previous month\\\">\\n\" +\r\n\t\t\"        ");
      out.write("</a>\\n\" +\r\n\t\t\"       ");
      out.write("</td>\\n\" +\r\n\t\t\"       ");
      out.write("<td bgcolor=\\\"#4682B4\\\" colspan=\\\"5\\\">\\n\" +\r\n\t\t\"        ");
      out.write("<font color=\\\"white\\\" face=\\\"tahoma, verdana\\\" size=\\\"2\\\">\\n\" +\r\n\t\t\"         \" + arr_months[dt_datetime.getMonth()] + \" \" + dt_datetime.getFullYear() + \"\\n\" +\r\n\t\t\"        ");
      out.write("</font>\\n\" +\r\n\t\t\"       ");
      out.write("</td>\\n\" +\r\n\t\t\"       ");
      out.write("<td bgcolor=\\\"#4682B4\\\" align=\\\"right\\\">\\n\" +\r\n\t\t\"        ");
      out.write("<a href=\\\"javascript:window.opener.show_calendar('\" +\r\n\t\t           str_target+\"', '\"+dt2dtstr(dt_next_month)+\"'+' ' +document.cal.time.value);\\\">\\n\" +\r\n\t\t\"         ");
      out.write("<img src=\\\"/sfaimages/next.gif\\\" width=\\\"16\\\" height=\\\"16\\\" border=\\\"0\\\"\" +\r\n\t\t\"           alt=\\\"next month\\\">\\n\" +\r\n\t\t\"        ");
      out.write("</a>\\n\" +\r\n\t\t\"       ");
      out.write("</td>\\n\" +\r\n\t\t\"      ");
      out.write("</tr>\\n\"\r\n\t);\r\n\r\n\tvar dt_current_day = new Date(dt_firstday);\r\n\t// print weekdays titles\r\n\tstr_buffer += \"      ");
      out.write("<tr>\\n\";\r\n\tfor (var n=0; n");
      out.write("<7; n++)\r\n\t\tstr_buffer += \"       ");
      out.write("<td bgcolor=\\\"#87CEFA\\\">\\n\" +\r\n\t\t\"       ");
      out.write("<font color=\\\"white\\\" face=\\\"tahoma, verdana\\\" size=\\\"2\\\">\\n\" +\r\n\t\t\"        \" + week_days[(n_weekstart+n)%7] + \"\\n\" +\r\n\t\t\"       ");
      out.write("</font>");
      out.write("</td>\\n\";\r\n\t// print calendar table\r\n\tstr_buffer += \"      ");
      out.write("</tr>\\n\";\r\n\twhile (dt_current_day.getMonth() == dt_datetime.getMonth() ||\r\n\t\tdt_current_day.getMonth() == dt_firstday.getMonth()) {\r\n\t\t// print row heder\r\n\t\tstr_buffer += \"      ");
      out.write("<tr>\\n\";\r\n\t\tfor (var n_current_wday=0; n_current_wday");
      out.write("<7; n_current_wday++) {\r\n\t\t\t\tif (dt_current_day.getDate() == dt_datetime.getDate() &&\r\n\t\t\t\t\tdt_current_day.getMonth() == dt_datetime.getMonth())\r\n\t\t\t\t\t// print current date\r\n\t\t\t\t\tstr_buffer += \"       ");
      out.write("<td bgcolor=\\\"#FFB6C1\\\" align=\\\"right\\\">\\n\";\r\n\t\t\t\telse if (dt_current_day.getDay() == 0 || dt_current_day.getDay() == 6)\r\n\t\t\t\t\t// weekend days\r\n\t\t\t\t\tstr_buffer += \"       ");
      out.write("<td bgcolor=\\\"#DBEAF5\\\" align=\\\"right\\\">\\n\";\r\n\t\t\t\telse\r\n\t\t\t\t\t// print working days of current month\r\n\t\t\t\t\tstr_buffer += \"       ");
      out.write("<td bgcolor=\\\"white\\\" align=\\\"right\\\">\\n\";\r\n\r\n\t\t\t\tif (isDateTime == \"1\" )\r\n\t\t\t\t\tstr_buffer += \"        ");
      out.write("<a href=\\\"javascript:window.opener.\" + str_target +\r\n\t\t\t\t\t\t\".value='\"+dt2dtstr(dt_current_day)+\"'+' ' +document.cal.time.value;window.close();\\\">\\n\";\r\n\t\t\t\telse\r\n\t\t\t\t\tstr_buffer += \"        ");
      out.write("<a href=\\\"javascript:window.opener.\" + str_target +\r\n\t\t\t\t\t\t\".value='\"+dt2dtstr(dt_current_day)+\"';window.close();\\\">\\n\";\r\n\t\t\t\t\t\r\n\t\t\t\tif (dt_current_day.getMonth() == dt_datetime.getMonth())\r\n\t\t\t\t\t// print days of current month\r\n\t\t\t\t\tstr_buffer += \"         ");
      out.write("<font color=\\\"black\\\" face=\\\"tahoma, verdana\\\" size=\\\"2\\\">\\n\";\r\n\t\t\t\telse \r\n\t\t\t\t\t// print days of other months\r\n\t\t\t\t\tstr_buffer += \"         ");
      out.write("<font color=\\\"gray\\\" face=\\\"tahoma, verdana\\\" size=\\\"2\\\">\\n\";\r\n\t\t\t\t\t\r\n\t\t\t\tstr_buffer += \"          \" + dt_current_day.getDate() + \"\\n\" +\r\n\t\t\t\t\"         ");
      out.write("</font>\\n\" +\r\n\t\t\t\t\"        ");
      out.write("</a>\\n\" +\r\n\t\t\t\t\"       ");
      out.write("</td>\\n\";\r\n\t\t\t\tdt_current_day.setDate(dt_current_day.getDate()+1);\r\n\t\t}\r\n\t\t// print row footer\r\n\t\tstr_buffer += \"      ");
      out.write("</tr>\\n\";\r\n\t}\r\n\t// print calendar footer\r\n\tstr_buffer +=\r\n\t\t\"      ");
      out.write("<form name=\\\"cal\\\">\\n\" +\r\n\t\t\"       ");
      out.write("<tr>\\n\" +\r\n\t\t\"        ");
      out.write("<td colspan=\\\"7\\\" bgcolor=\\\"#87CEFA\\\">\\n\" +\r\n\t\t\"         ");
      out.write("<font color=\\\"White\\\" face=\\\"tahoma, verdana\\\" size=\\\"2\\\">\\n\" +\r\n\t\t\"          Time:\\n\" +\r\n\t\t\"          ");
      out.write("<input type=\\\"text\\\" name=\\\"time\\\" value=\\\"\" + dt2tmstr(dt_datetime) +\r\n\t\t\"\\\" size=\\\"8\\\" maxlength=\\\"8\\\">\\n\" +\r\n\t\t\"         ");
      out.write("</font>\\n\" +\r\n\t\t\"        ");
      out.write("</td>\\n\" +\r\n\t\t\"       ");
      out.write("</tr>\\n\" +\r\n\t\t\"      ");
      out.write("</form>\\n\" +\r\n\t\t\"     ");
      out.write("</table>\\n\" +\r\n\t\t\"    ");
      out.write("</tr>\\n\" +\r\n\t\t\"   ");
      out.write("</td>\\n\" +\r\n\t\t\"  ");
      out.write("</table>\\n\" +\r\n\t\t\" ");
      out.write("</body>\\n\" +\r\n\t\t\"");
      out.write("</html>\\n\";\r\n\r\n\t//alert(\"Fixin to open window\");\r\n\tvar vWinCal = window.open(\"\", \"Calendar\", \r\n\t\t\"width=200,height=250,status=no,resizable=yes,top=200,left=200\");\r\n\t//alert(\"Fixin to set window opener to self\");\r\n\tvWinCal.opener = self;\r\n\tvar calc_doc = vWinCal.document;\r\n\t//alert(\"Fixin to write str_buffer\");\r\n\tcalc_doc.write (str_buffer);\r\n\tcalc_doc.close();\r\n}\r\n// datetime parsing and formatting routimes. modify them if you wish other datetime format\r\nfunction str2datetime (str_datetime) {\r\n\tvar re_date = /^(\\d+)\\/(\\d+)\\/(\\d+)\\s+(\\d+)\\:(\\d+)\\:(\\d+)$/;\r\n\tif (!re_date.exec(str_datetime))\r\n\t\treturn str2date(str_datetime)\r\n\treturn (new Date (RegExp.$3, RegExp.$1-1, RegExp.$2, RegExp.$4, RegExp.$5, RegExp.$6));\r\n}\r\nfunction str2date (str_date) {\r\n\tvar re_date = /^(\\d+)\\/(\\d+)\\/(\\d+)$/;\r\n\tif (!re_date.exec(str_date))\r\n\t\treturn alert(\"Invalid Date format: \"+ str_date);\r\n\treturn (new Date (RegExp.$3, RegExp.$1-1, RegExp.$2, 0, 0, 0));\r\n}\r\n\r\nfunction dt2dtstr (dt_datetime) {\r\n\treturn (new String (\r\n\t\t\t(dt_datetime.getMonth()+1)+\"/\"+dt_datetime.getDate()+\"/\"+dt_datetime.getFullYear()));\r\n");
      out.write("}\r\nfunction dt2tmstr (dt_datetime) {\r\n\treturn (new String (\r\n\t\t\tdt_datetime.getHours()+\":\"+dt_datetime.getMinutes()+\":\"+dt_datetime.getSeconds()));\r\n}\r\n\r\n");
      out.write("</script>\r\n");
      out.write("\r\n\r\n");
      out.write("\r\n");


// Define the roles.
String ROLE_SFA_ADMIN = "SFA_ADMIN";
String ROLE_SFA_USER = "SFA_USER";
String ROLE_SFA_LEADS_ADMIN = "SFA_LEADS_ADMIN";
String ROLE_SFA_LEADS_USER = "SFA_LEADS_USER";

// Define menu items on Sales menu.
Integer MENU_DASHBOARD = new Integer(100);
Integer MENU_LEADS = new Integer(101);
Integer MENU_ACCOUNTS = new Integer(102);
Integer MENU_CONTACTS = new Integer(103);
Integer MENU_OPPORTUNITIES = new Integer(104);
Integer MENU_ACTIVITIES = new Integer(105);
Integer MENU_TIME_MANAGEMENT = new Integer(106);
Integer MENU_FORECASTS = new Integer(107);
Integer MENU_PRODUCTS = new Integer(108);
Integer MENU_TERRITORIES = new Integer(109);
Integer MENU_XFER = new Integer(110);

// Define menu items on Services menu.
Integer MENU_ISSUE_TRACKING = new Integer(200);
Integer MENU_CURRENT_ISSUES = new Integer(201);
Integer MENU_ISSUE_CHARTS = new Integer(202);

// Define menu items on Reports menu.
Integer MENU_ACCOUNT_LIST_RPT = new Integer(300);
Integer MENU_CONTACT_LIST_RPT = new Integer(301);
Integer MENU_PIPELINE_RPT = new Integer(302);
Integer MENU_PIPELINE_CHART = new Integer(303);
Integer MENU_WIN_LOSS_RPT = new Integer(304);
Integer MENU_ACTIVITIES_RPT = new Integer(305);
Integer MENU_OPPORTUNITY_OVERVIEW_RPT = new Integer(306);
Integer MENU_REPORT_BUILDER_RPT = new Integer(307);

// Define menu items on Admin menu.
Integer MENU_MY_COMPANY = new Integer(400);
Integer MENU_APPLICATIONS = new Integer(401);
Integer MENU_SCREENS = new Integer(402);
Integer MENU_ENTITIES = new Integer(403);
Integer MENU_CODES = new Integer(404);
Integer MENU_DISPLAY_TYPES = new Integer(405);
Integer MENU_PREFERENCES = new Integer(406);
Integer MENU_LEAD_QUEUES = new Integer(407);
Integer MENU_LEAD_RULES = new Integer(408);
Integer MENU_STEPS_TO_CLOSE = new Integer(409);
Integer MENU_REPLICATION = new Integer(410);
Integer MENU_SQL_QUERY = new Integer(411);
Integer MENU_USER_TRANSFER = new Integer(412);

// Define privileges for SFA Admin role.
ArrayList menuPrivsSfaAdmin = new ArrayList();
menuPrivsSfaAdmin.add( MENU_DASHBOARD );
menuPrivsSfaAdmin.add( MENU_LEADS );
menuPrivsSfaAdmin.add( MENU_ACCOUNTS );
menuPrivsSfaAdmin.add( MENU_CONTACTS );
menuPrivsSfaAdmin.add( MENU_OPPORTUNITIES );
menuPrivsSfaAdmin.add( MENU_ACTIVITIES );
menuPrivsSfaAdmin.add( MENU_TIME_MANAGEMENT );
menuPrivsSfaAdmin.add( MENU_FORECASTS );
menuPrivsSfaAdmin.add( MENU_PRODUCTS );
menuPrivsSfaAdmin.add( MENU_TERRITORIES );
menuPrivsSfaAdmin.add( MENU_XFER );
menuPrivsSfaAdmin.add( MENU_ISSUE_TRACKING );
menuPrivsSfaAdmin.add( MENU_CURRENT_ISSUES );
menuPrivsSfaAdmin.add( MENU_ISSUE_CHARTS );
menuPrivsSfaAdmin.add( MENU_ACCOUNT_LIST_RPT );
menuPrivsSfaAdmin.add( MENU_CONTACT_LIST_RPT );
menuPrivsSfaAdmin.add( MENU_PIPELINE_RPT );
menuPrivsSfaAdmin.add( MENU_PIPELINE_CHART );
menuPrivsSfaAdmin.add( MENU_WIN_LOSS_RPT );
menuPrivsSfaAdmin.add( MENU_ACTIVITIES_RPT );
menuPrivsSfaAdmin.add( MENU_OPPORTUNITY_OVERVIEW_RPT );
menuPrivsSfaAdmin.add( MENU_REPORT_BUILDER_RPT );
menuPrivsSfaAdmin.add( MENU_MY_COMPANY );
menuPrivsSfaAdmin.add( MENU_APPLICATIONS );
menuPrivsSfaAdmin.add( MENU_SCREENS );
menuPrivsSfaAdmin.add( MENU_ENTITIES );
menuPrivsSfaAdmin.add( MENU_CODES );
menuPrivsSfaAdmin.add( MENU_DISPLAY_TYPES );
menuPrivsSfaAdmin.add( MENU_PREFERENCES );
menuPrivsSfaAdmin.add( MENU_LEAD_QUEUES );
menuPrivsSfaAdmin.add( MENU_LEAD_RULES );
menuPrivsSfaAdmin.add( MENU_STEPS_TO_CLOSE );
menuPrivsSfaAdmin.add( MENU_REPLICATION );
menuPrivsSfaAdmin.add( MENU_SQL_QUERY );
menuPrivsSfaAdmin.add( MENU_USER_TRANSFER );

// Define privileges for SFA User role.
ArrayList menuPrivsSfaUser = new ArrayList();
menuPrivsSfaUser.add( MENU_DASHBOARD );
menuPrivsSfaUser.add( MENU_LEADS );
menuPrivsSfaUser.add( MENU_ACCOUNTS );
menuPrivsSfaUser.add( MENU_CONTACTS );
menuPrivsSfaUser.add( MENU_OPPORTUNITIES );
menuPrivsSfaUser.add( MENU_ACTIVITIES );
menuPrivsSfaUser.add( MENU_TIME_MANAGEMENT );
menuPrivsSfaUser.add( MENU_FORECASTS );
menuPrivsSfaUser.add( MENU_PRODUCTS );
menuPrivsSfaUser.add( MENU_XFER );
menuPrivsSfaUser.add( MENU_ISSUE_TRACKING );
menuPrivsSfaUser.add( MENU_CURRENT_ISSUES );
menuPrivsSfaUser.add( MENU_ISSUE_CHARTS );
menuPrivsSfaUser.add( MENU_ACCOUNT_LIST_RPT );
menuPrivsSfaUser.add( MENU_CONTACT_LIST_RPT );
menuPrivsSfaUser.add( MENU_PIPELINE_RPT );
menuPrivsSfaUser.add( MENU_PIPELINE_CHART );
menuPrivsSfaUser.add( MENU_WIN_LOSS_RPT );
menuPrivsSfaUser.add( MENU_ACTIVITIES_RPT );
menuPrivsSfaUser.add( MENU_OPPORTUNITY_OVERVIEW_RPT );
menuPrivsSfaUser.add( MENU_REPORT_BUILDER_RPT );
menuPrivsSfaUser.add( MENU_REPLICATION );
menuPrivsSfaUser.add( MENU_XFER );

// Define privileges for SFA Leads Admin role.
ArrayList menuPrivsSfaLeadsAdmin = new ArrayList();
menuPrivsSfaLeadsAdmin.add( MENU_DASHBOARD );
menuPrivsSfaLeadsAdmin.add( MENU_LEADS );
menuPrivsSfaLeadsAdmin.add( MENU_ACCOUNTS );
menuPrivsSfaLeadsAdmin.add( MENU_CONTACTS );
menuPrivsSfaLeadsAdmin.add( MENU_ACTIVITIES );
menuPrivsSfaLeadsAdmin.add( MENU_TIME_MANAGEMENT );
menuPrivsSfaLeadsAdmin.add( MENU_TERRITORIES );
menuPrivsSfaLeadsAdmin.add( MENU_XFER );
menuPrivsSfaLeadsAdmin.add( MENU_ISSUE_TRACKING );
menuPrivsSfaLeadsAdmin.add( MENU_CURRENT_ISSUES );
menuPrivsSfaLeadsAdmin.add( MENU_ISSUE_CHARTS );
menuPrivsSfaLeadsAdmin.add( MENU_ACTIVITIES_RPT );
menuPrivsSfaLeadsAdmin.add( MENU_REPORT_BUILDER_RPT );
menuPrivsSfaLeadsAdmin.add( MENU_MY_COMPANY );
menuPrivsSfaLeadsAdmin.add( MENU_SCREENS );
menuPrivsSfaLeadsAdmin.add( MENU_CODES );
menuPrivsSfaLeadsAdmin.add( MENU_PREFERENCES );
menuPrivsSfaLeadsAdmin.add( MENU_LEAD_QUEUES );
menuPrivsSfaLeadsAdmin.add( MENU_LEAD_RULES );
menuPrivsSfaLeadsAdmin.add( MENU_XFER );

// Define privileges for SFA Leads User role.
ArrayList menuPrivsSfaLeadsUser = new ArrayList();
menuPrivsSfaLeadsUser.add( MENU_DASHBOARD );
menuPrivsSfaLeadsUser.add( MENU_LEADS );
menuPrivsSfaLeadsUser.add( MENU_ACTIVITIES );
menuPrivsSfaLeadsUser.add( MENU_TIME_MANAGEMENT );
menuPrivsSfaLeadsUser.add( MENU_ACTIVITIES_RPT );
menuPrivsSfaLeadsUser.add( MENU_REPORT_BUILDER_RPT );
menuPrivsSfaLeadsUser.add( MENU_XFER );


ArrayList menuPrivileges = new ArrayList();

String module = "getMenuPrivileges";

if (userInfo!=null && userInfo.getPartyId()!=null && !userInfo.getPartyId().equals("")) {

  // User is logged in. Get the user's roles.
  HashMap partyRoleFindMap = new HashMap();
  partyRoleFindMap.put("partyId", userInfo.getPartyId());
  try {
    List partyRoleL = delegator.findByAnd("PartyRole", partyRoleFindMap);
 
    Iterator partyRoleI = partyRoleL.iterator();
    while (partyRoleI.hasNext()) {
View Full Code Here

      out.write("<!-- [oldFunctions.jsp] End -->\r\n\r\n");
      out.write("\r\n");
      out.write("<!-- [oldDeclarations.jsp] Start -->\r\n\r\n");
GenericValue userLogin = (GenericValue)session.getAttribute("_USER_LOGIN_");
      out.write("\r\n");
UserInfo userInfo  = (UserInfo) session.getAttribute("userInfo");
      out.write("\r\n\r\n");
  String partyId = "";
  if (userLogin != null )
       partyId = userLogin.getString("partyId");
View Full Code Here

      out.write("<!-- [oldFunctions.jsp] End -->\r\n\r\n");
      out.write("\r\n");
      out.write("<!-- [oldDeclarations.jsp] Start -->\r\n\r\n");
GenericValue userLogin = (GenericValue)session.getAttribute("_USER_LOGIN_");
      out.write("\r\n");
UserInfo userInfo  = (UserInfo) session.getAttribute("userInfo");
      out.write("\r\n\r\n");
  String partyId = "";
  if (userLogin != null )
       partyId = userLogin.getString("partyId");
View Full Code Here

String action = request.getParameter("action");
if ( (action == null ) || ( action.length() < 1) )
{
   Preference pref = Preference.getInstance(delegator);
   UserInfo userInfo  = (UserInfo) session.getAttribute("userInfo");
   action = pref.getPreference( userInfo.getPartyId(), userInfo.getAccountId(), "SCREEN_ACTION", UIScreenSection.ACTION_SHOW_INSERT);
}


      out.write("\r\n\r\n");
View Full Code Here

      out.write("<!-- [oldFunctions.jsp] End -->\r\n\r\n");
      out.write("\r\n");
      out.write("<!-- [oldDeclarations.jsp] Start -->\r\n\r\n");
GenericValue userLogin = (GenericValue)session.getAttribute("_USER_LOGIN_");
      out.write("\r\n");
UserInfo userInfo  = (UserInfo) session.getAttribute("userInfo");
      out.write("\r\n\r\n");
  String partyId = "";
  if (userLogin != null )
       partyId = userLogin.getString("partyId");

      out.write("\r\n\r\n");

   DecimalFormat decimalFormat = new DecimalFormat("#,###.##");
   SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM/dd/yyyy");
   SimpleDateFormat simpleTimeFormat = new SimpleDateFormat("K:mm a");

      out.write("\r\n\r\n");
String controlPath=(String)request.getAttribute("_CONTROL_PATH_");
      out.write("\r\n");
String contextRoot=(String)request.getAttribute("_CONTEXT_ROOT_");
      out.write("\r\n\r\n");
String pageName = UtilFormatOut.checkNull((String)pageContext.getAttribute("PageName"));
      out.write("\r\n\r\n");
String companyName = UtilProperties.getPropertyValue(contextRoot + "/WEB-INF/sfa.properties", "company.name");
      out.write("\r\n");
String companySubtitle = UtilProperties.getPropertyValue(contextRoot + "/WEB-INF/sfa.properties", "company.subtitle");
      out.write("\r\n");
String headerImageUrl = UtilProperties.getPropertyValue(contextRoot + "/WEB-INF/sfa.properties", "header.image.url");
      out.write("\r\n\r\n");
String headerBoxBorderColor = UtilProperties.getPropertyValue(contextRoot + "/WEB-INF/sfa.properties", "header.box.border.color", "black");
      out.write("\r\n");
String headerBoxBorderWidth = UtilProperties.getPropertyValue(contextRoot + "/WEB-INF/sfa.properties", "header.box.border.width", "1");
      out.write("\r\n");
String headerBoxTopColor = UtilProperties.getPropertyValue(contextRoot + "/WEB-INF/sfa.properties", "header.box.top.color", "#336699");
      out.write("\r\n");
String headerBoxBottomColor = UtilProperties.getPropertyValue(contextRoot + "/WEB-INF/sfa.properties", "header.box.bottom.color", "#cccc99");
      out.write("\r\n");
String headerBoxBottomColorAlt = UtilProperties.getPropertyValue(contextRoot + "/WEB-INF/sfa.properties", "header.box.bottom.alt.color", "#eeeecc");
      out.write("\r\n");
String headerBoxTopPadding = UtilProperties.getPropertyValue(contextRoot + "/WEB-INF/sfa.properties", "header.box.top.padding", "4");
      out.write("\r\n");
String headerBoxBottomPadding = UtilProperties.getPropertyValue(contextRoot + "/WEB-INF/sfa.properties", "header.box.bottom.padding", "2");
      out.write("\r\n\r\n");
String boxBorderColor = UtilProperties.getPropertyValue(contextRoot + "/WEB-INF/sfa.properties", "box.border.color", "black");
      out.write("\r\n");
String boxBorderWidth = UtilProperties.getPropertyValue(contextRoot + "/WEB-INF/sfa.properties", "box.border.width", "1");
      out.write("\r\n");
String boxTopColor = UtilProperties.getPropertyValue(contextRoot + "/WEB-INF/sfa.properties", "box.top.color", "#336699");
      out.write("\r\n");
String boxBottomColor = UtilProperties.getPropertyValue(contextRoot + "/WEB-INF/sfa.properties", "box.bottom.color", "white");
      out.write("\r\n");
String boxBottomColorAlt = UtilProperties.getPropertyValue(contextRoot + "/WEB-INF/sfa.properties", "box.bottom.alt.color", "white");
      out.write("\r\n");
String boxTopPadding = UtilProperties.getPropertyValue(contextRoot + "/WEB-INF/sfa.properties", "box.top.padding", "4");
      out.write("\r\n");
String boxBottomPadding = UtilProperties.getPropertyValue(contextRoot + "/WEB-INF/sfa.properties", "box.bottom.padding", "4");
      out.write("\r\n");
String userStyleSheet = "/sfa/includes/maincss.css";
      out.write("\r\n");
String alphabet[]={"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "*"};
      out.write("\r\n\r\n");
      out.write("<!-- [oldDeclarations.jsp] End -->\r\n\r\n");
      out.write("\r\n\r\n");
      out.write("<HTML>\r\n");
      out.write("<HEAD>\r\n\r\n");

String clientRequest = (String)session.getAttribute("_CLIENT_REQUEST_");
//out.write("Client request: " + clientRequest + "<BR>");
String hostName = "";
if (clientRequest!=null && clientRequest.indexOf("//") > 0) {
int startPos = clientRequest.indexOf("//") + 2;
int endPos = clientRequest.indexOf(":", startPos);
if ( endPos < startPos )
   endPos = clientRequest.indexOf("/", startPos);
if ( endPos < startPos )
   hostName = clientRequest.substring(startPos);
else
    hostName = clientRequest.substring(startPos, endPos);
} else {
hostName = "";
}
//out.write("Host name: " + hostName + "<BR>");

      out.write("\r\n\r\n");
      out.write("<title>");
      out.print(hostName);
      out.write(" - Sales Force Automation - ");
      out.print(companyName);
      out.write("</title>\r\n\r\n");
      out.write("\r\n");
      out.write("<!-- [userStyle.jsp] Start -->\r\n\r\n");

//------------ Get the style sheet
String styleSheetId = null;

ModelEntity entityStyleUser = delegator.getModelEntity("UiUserTemplate");
HashMap hashMapStyleUser = new HashMap();
if ( userLogin != null ) {
  String ulogin = userLogin.getString("userLoginId");
  hashMapStyleUser.put("userLoginId", ulogin);
} else {
  hashMapStyleUser.put("userLoginId", "Default");
}
GenericPK stylePk = new GenericPK(entityStyleUser, hashMapStyleUser);
GenericValue userTemplate = delegator.findByPrimaryKey(stylePk);
if ( userTemplate != null ) {
  styleSheetId = userTemplate.getString("styleSheetId");
}

if (styleSheetId == null){
  hashMapStyleUser.put("userLoginId", "Default");
  stylePk = new GenericPK(entityStyleUser, hashMapStyleUser);
  userTemplate = delegator.findByPrimaryKey(stylePk);
  if ( userTemplate != null ) {
    styleSheetId = userTemplate.getString("styleSheetId");
  }
}

if (styleSheetId != null){
  ModelEntity entityStyle = delegator.getModelEntity("UiStyleTemplate");
  HashMap hashMapStyle = new HashMap();
  hashMapStyle.put("styleSheetId", styleSheetId);
  stylePk = new GenericPK(entityStyle, hashMapStyle);
  GenericValue styleTemplate = delegator.findByPrimaryKey(stylePk);
  userStyleSheet = styleTemplate.getString("styleSheetLoc");

  if ( userStyleSheet == null ){
    userStyleSheet = "/sfa/includes/maincss.css";
  }
}


      out.write("\r\n");
      out.write("<link rel=\"stylesheet\" href=\"");
      out.print(userStyleSheet);
      out.write("\" type=\"text/css\">\r\n\r\n");
      out.write("<!-- [userStyle.jsp] End -->\r\n\r\n");
      out.write("\r\n");
      out.write("<LINK rel=\"stylesheet\" type=\"text/css\" href=\"/sfa/css/gridstyles.css\">\r\n");
      out.write("<script language=\"JavaScript\" >\r\n\r\n  function sendDropDown(elementName, idName, fieldName, findClass, paramName, paramValue, frm, action)\r\n  {\r\n        var sUrl = '");
      if (_jspx_meth_ofbiz_url_0(pageContext))
        return;
      out.write("?findMode=filter&fieldName=' +\r\n\t\t\tfieldName + '&idName=' + idName + '&param_' + paramName + '=' + paramValue +\r\n\t\t\t'&formName=' + frm.name + '&elementName=' + elementName + '&findClass=' + findClass + '&action=' + action;\r\n        document.anchors('searchA').href=sUrl;\r\n        document.anchors('searchA').click();\r\n  }\r\n\r\n\r\n  function sendData(ele, frm, action){\r\n    if(ele.tagName != 'SELECT'){\r\n      if(ele.value.length > 0){\r\n        entity = ele.getAttribute(\"entityName\");\r\n        field = ele.getAttribute(\"fieldName\");\r\n        idName = ele.getAttribute(\"idName\");\r\n        findClass = ele.getAttribute(\"findClass\");\r\n        findValue = ele.value;\r\n        elementName = ele.name;\r\n        var sUrl = '");
      if (_jspx_meth_ofbiz_url_1(pageContext))
        return;
      out.write("?entityName=' + entity + '&fieldName=' +\r\n\t\t\tfield + '&idName=' + idName + '&findByLikeValue=' + findValue + '&formName=' + frm.name +\r\n\t\t\t'&elementName=' + elementName + '&findClass=' + findClass + '&action=' + action;\r\n        document.anchors('searchA').href=sUrl;\r\n        document.anchors('searchA').click();\r\n      } else {\r\n        //alert('Enter search criteria to find a value.');\r\n        //frm.item(ele.name).value = 'Enter search criteria.';\r\n      }\r\n    }\r\n  }\r\n\r\n  function updateForm(){\r\n    var innDoc = document.frames('searchIFrame').document;\r\n    var innHtml = innDoc.body.innerHTML;\r\n    if(innHtml.length > 0){\r\n      var sDiv = innDoc.all('searchResultDiv');\r\n      if(sDiv != null){\r\n        var formName = sDiv.getAttribute(\"formName\");\r\n        var fieldName = sDiv.getAttribute(\"fieldName\");\r\n        var elementName = sDiv.getAttribute(\"elementName\");\r\n        var findClass = sDiv.getAttribute(\"findClass\");\r\n        var findMode = sDiv.getAttribute(\"findMode\");\r\n        var showMultiple = sDiv.getAttribute(\"showMultiple\");\r\n");
      out.write("        var nde = innDoc.all(elementName);\r\n        var existingNode = document.all(elementName);\r\n        if(nde != null){\r\n          var frm = document.forms(formName);\r\n          if(nde.tagName == 'SELECT'){\r\n            var opts = nde.children.tags('OPTION');\r\n            if ( findMode == 'filter')\r\n            {\r\n\t\t\t\tvar oldOpts = existingNode.children.tags('OPTION');\r\n//\t\t\t\talert('oldOpts.length = ' + oldOpts.length);\r\n//\t\t\t\talert('opts.length = ' + opts.length);\r\n\t\t\t\tvar numOpt = existingNode.options.length;\r\n//\t\t\t\talert('numOpt = ' + numOpt);\r\n\t\t\t\tfor (var i=0; i");
      out.write("<numOpt;i++)\r\n\t\t\t\t\texistingNode.options.remove(numOpt - 1 - i);\r\n\t\t\t\tfor (var i=0; i");
      out.write("<opts.length;i++)\r\n\t\t\t\t{\r\n\t\t\t\t\tvar opt = document.createElement(\"option\");\r\n\t\t\t\t\topt.setAttribute(\"value\", opts(i).value);\r\n\t\t\t\t\topt.innerText = opts(i).innerText;\r\n\t\t\t\t\texistingNode.appendChild(opt);\r\n\t\t\t\t}\r\n            }\r\n            else if(opts.length");
      out.write("<=0){\r\n              //alert('No results were found.  Please try another search.');\r\n              existingNode.focus();\r\n            } else {\r\n              var ele = document.createElement(nde.tagName);\r\n              ele.id = nde.name;\r\n              ele.name = nde.name;\r\n              ele.setAttribute(\"className\", existingNode.getAttribute(\"className\"));\r\n\t\t\t  ele.setAttribute(\"entityName\", sDiv.getAttribute(\"entityName\"));\r\n              ele.setAttribute(\"fieldName\", sDiv.getAttribute(\"fieldName\"));\r\n              ele.setAttribute(\"elementName\", sDiv.getAttribute(\"elementName\"));\r\n              ele.setAttribute(\"idName\",  sDiv.getAttribute(\"idName\"));\r\n              ele.setAttribute(\"findClass\",  sDiv.getAttribute(\"findClass\"));\r\n              if (showMultiple == \"true\") ele.multiple = true;\r\n              ele.tabIndex = existingNode.tabIndex;\r\n              ele.attachEvent(\"onchange\", searchAgain);\r\n              for(var i=0;i");
      out.write("<opts.length;i++){\r\n                var opt = document.createElement(\"option\");\r\n                opt.setAttribute(\"value\", opts(i).value);\r\n                opt.innerText = opts(i).innerText;\r\n                ele.appendChild(opt);\r\n              }\r\n              var opt = document.createElement(\"option\");\r\n              opt.setAttribute(\"value\", \"search again\");\r\n              opt.innerText = \"Search again...\";\r\n              ele.appendChild(opt);\r\n              var sRepNde = elementName + 'Holder';\r\n              var repNde = document.all(sRepNde);\r\n              repNde.replaceChild(ele, existingNode);\r\n              ele.focus();\r\n\t      ele.fireEvent(\"onchange\");\r\n            }\r\n          }\r\n        }\r\n      }\r\n    }\r\n  }\r\n\r\n  function searchAgain(sel, frm){\r\n    if(sel.tagName == 'SELECT'){\r\n      var fieldName = sel.getAttribute('fieldName');\r\n      var findClass = sel.getAttribute('findClass');\r\n      var elementName = sel.name;\r\n      var formName = frm.name;\r\n      var existingNode = document.all(elementName);\r\n");
      out.write("      if(sel.value == 'search again'){\r\n        var ele = document.createElement(\"INPUT\");\r\n        ele.id = sel.name;\r\n        ele.name = sel.name;\r\n        ele.type = \"TEXT\";\r\n        ele.setAttribute(\"className\", existingNode.getAttribute(\"className\"));\r\n        ele.setAttribute(\"entityName\", sel.getAttribute(\"entityName\"));\r\n        ele.setAttribute(\"fieldName\", fieldName);\r\n        ele.setAttribute(\"elementName\", elementName);\r\n        ele.setAttribute(\"idName\",  sel.getAttribute(\"idName\"));\r\n        ele.setAttribute(\"findClass\",  findClass);\r\n        ele.tabIndex = sel.tabIndex;\r\n        var sRepNde = elementName + 'Holder';\r\n        var repNde = document.all(sRepNde);\r\n        repNde.replaceChild(ele, existingNode);\r\n        ele.focus();\r\n      }\r\n    }\r\n  }\r\n\r\n  // currently only used by accountPopup to force activity_accountId to be a select field\r\n  function forceSearchAgain(sel, frm){\r\n    if(sel.tagName == 'SELECT'){\r\n      var fieldName = sel.getAttribute('fieldName');\r\n      var findClass = sel.getAttribute('findClass');\r\n");
      out.write("      var elementName = sel.name;\r\n      var formName = frm.name;\r\n      var existingNode = document.all(elementName);\r\n\t  var ele = document.createElement(\"INPUT\");\r\n\t  ele.id = sel.name;\r\n\t  ele.name = sel.name;\r\n\t  ele.type = \"TEXT\";\r\n\t  ele.setAttribute(\"className\", existingNode.getAttribute(\"className\"));\r\n\t  ele.setAttribute(\"entityName\", sel.getAttribute(\"entityName\"));\r\n\t  ele.setAttribute(\"fieldName\", fieldName);\r\n\t  ele.setAttribute(\"elementName\", elementName);\r\n\t  ele.setAttribute(\"idName\",  sel.getAttribute(\"idName\"));\r\n\t  ele.setAttribute(\"findClass\",  findClass);\r\n\t  ele.tabIndex = sel.tabIndex;\r\n\t  var sRepNde = elementName + 'Holder';\r\n\t  var repNde = document.all(sRepNde);\r\n\t  repNde.replaceChild(ele, existingNode);\r\n    }\r\n  }\r\n\r\nvar currentCol = 0;\r\nvar previousCol = -1;\r\nvar reverse = false;\r\n\r\n  function CompareAlpha(a, b) {\r\n    if (a[currentCol] ");
      out.write("< b[currentCol]) { return -1; }\r\n    if (a[currentCol] > b[currentCol]) { return 1; }\r\n    return 0;\r\n  }\r\n\r\n  function CompareAlphaIgnore(a, b) {\r\n    strA = a[currentCol].toLowerCase();\r\n    strB = b[currentCol].toLowerCase();\r\n    if (strA ");
      out.write("< strB) { return -1;\r\n    } else {\r\n      if (strA > strB) { return 1;\r\n      } else { return 0;\r\n      }\r\n    }\r\n  }\r\n\r\n  function CompareDate(a, b) {\r\n    datA = new Date(a[currentCol]);\r\n    datB = new Date(b[currentCol]);\r\n    if (datA ");
      out.write("< datB) { return -1;\r\n    } else {\r\n      if (datA > datB) { return 1;\r\n      } else { return 0;\r\n      }\r\n    }\r\n  }\r\n\r\n  function CompareDateEuro(a, b) {\r\n    strA = a[currentCol].split(\".\");\r\n    strB = b[currentCol].split(\".\");\r\n    datA = new Date(strA[2], strA[1], strA[0]);\r\n    datB = new Date(strB[2], strB[1], strB[0]);\r\n    if (datA ");
      out.write("< datB) { return -1;\r\n    } else {\r\n      if (datA > datB) { return 1;\r\n      } else { return 0;\r\n      }\r\n    }\r\n  }\r\n\r\n  function CompareNumeric(a, b) {\r\n    numA = a[currentCol];\r\n    numB = b[currentCol];\r\n    if (isNaN(numA)) { return 0;\r\n    } else {\r\n      if (isNaN(numB)) { return 0;\r\n      } else { return numA - numB;\r\n      }\r\n    }\r\n  }\r\n\r\nfunction TableSort(myTable, myCol, myType) {\r\n\r\n  var mySource = document.all(myTable);\r\n  var myRows = mySource.rows.length;\r\n  var myCols = mySource.rows(0).cells.length;\r\n  currentCol = myCol\r\n\r\n  var theadrow = mySource.parentElement.tHead;\r\n  var imgcol= theadrow.all('srtImg');\r\n  for(var x = 0; x ");
      out.write("< imgcol.length; x++){\r\n    imgcol[x].src = \"dude07232001blank.gif\";\r\n    imgcol[x].alt = \"sort\";\r\n  }\r\n\r\n  if(previousCol == myCol){\r\n    if(reverse == false){\r\n      imgcol[myCol-1].src = \"dude07232001down.gif\";\r\n      reverse = true;\r\n    } else {\r\n      imgcol[myCol-1].src = \"dude07232001up.gif\";\r\n      reverse = false;\r\n    }\r\n  } else {\r\n    reverse = false;\r\n    imgcol[myCol-1].src = \"dude07232001up.gif\";\r\n  }\r\n\r\n  myArray = new Array(myRows)\r\n  for (i=0; i ");
      out.write("< myRows; i++) {\r\n    myArray[i] = new Array(myCols)\r\n    for (j=0; j ");
      out.write("< myCols; j++) {\r\n      myArray[i][j] = document.all(myTable).rows(i).cells(j).innerHTML;\r\n    }\r\n  }\r\n\r\n  if (myCol == previousCol) {\r\n    myArray.reverse();\r\n  } else {\r\n    switch (myType) {\r\n      case \"a\":\r\n        myArray.sort(CompareAlpha);\r\n        break;\r\n      case \"ai\":\r\n        myArray.sort(CompareAlphaIgnore);\r\n        break;\r\n      case \"d\":\r\n        myArray.sort(CompareDate);\r\n        break;\r\n      case \"de\":\r\n        myArray.sort(CompareDateEuro);\r\n        break;\r\n      case \"n\":\r\n        myArray.sort(CompareNumeric);\r\n        break;\r\n      default:\r\n        myArray.sort();\r\n    }\r\n  }\r\n\r\n\r\n  // Re-write the table contents\r\n  for (i=0; i ");
      out.write("< myRows; i++) {\r\n    for (j=0; j ");
      out.write("< myCols; j++) {\r\n      mySource.rows(i).cells(j).innerHTML = myArray[i][j];\r\n    }\r\n  }\r\n\r\n  previousCol = myCol;\r\n  highlightSelectedRow();\r\n  return 0;\r\n\r\n}\r\n\r\n  function fixSize() {\r\n      // The body represents the outer-most frameset for frameset documents.\r\n      if ( parent.name == \"content\" )\r\n      {\r\n\t      maxH = parent.document.body.clientHeight - 150;\r\n\t      topH = document.body.scrollHeight + 10;\r\n\t      if ( topH > maxH )\r\n\t      \ttopH = maxH;\r\n\t      \t\r\n\t      parent.document.body.rows = topH + \", *\"\r\n\t      //window.frames.headerFrame.document.body.rows = window.frames.headerFrame.document.body.scrollHeight + \", *\" \r\n\t      // Walk into the header frame and get the scrollHeight - \r\n\t      // this represents the height of the contents in pixels. \r\n\t  }\r\n  }\r\n");
      out.write("</script>\r\n\r\n\r\n");
      out.write("\r\n\r\n");
      out.write("</HEAD>\r\n\r\n");
      out.write("<BASE TARGET=\"content\">\r\n");
      out.write("<!--");
      out.write("<BODY CLASS=\"bodyform\" onbeforeunload=\"verifyClose()\">-->\r\n");
      out.write("<BODY CLASS=\"bodyform\"\">\r\n\r\n");
      out.write("\r\n");
      out.write("<!-- onBeforeUnload.jsp - Start -->\r\n\r\n");
      out.write("<SCRIPT LANGUAGE=\"JScript\" TYPE=\"text/javascript\" FOR=window EVENT=onbeforeunload>\r\n return doOnBeforeUnload();\r\n");
      out.write("</SCRIPT>\r\n\r\n");
      out.write("<SCRIPT LANGUAGE=\"JScript\" TYPE=\"text/javascript\">\r\n\r\n // Create variable we can change to prevent the check from being done.\r\n var checkForChanges = true;\r\n \r\n function doOnBeforeUnload() {\r\n  // This script fires when anything is about to cause the current page to be unloaded.\r\n  // If any unsaved changes have been made, this script returns a non-empty string, which\r\n  // causes a response window to warn the user that changes will be lost, and to allow\r\n  // them to cancel.\r\n \r\n  // In free form, tabular, and select screen sections built by the UI builder,\r\n  // the preSubmit method fired by the onSubmit event of the form removes this script from\r\n  // the onBeforeUnload event, which prevents this check from happening if the Save button\r\n  // was just clicked.\r\n \r\n // alert(\"event.fromElement: \" + event.fromElement);\r\n \r\n  // See if the checkForChanges flag has been cleared. If so, just allow the\r\n  // body unload to continue.\r\n  if (!checkForChanges) return;\r\n \r\n  // Look at all forms on the page to see if any of them have any changes.\r\n");
      out.write("  var vFormC = document.forms;\r\n  for (var vFormNbr = 0; vFormNbr ");
      out.write("< vFormC.length; vFormNbr++) {\r\n   //alert(\"[verifyClose] Window name: \" + window.name);\r\n   //alert(\"[verifyClose] Checking form #\" + vFormNbr);\r\n   var vFormObj = vFormC.item(vFormNbr);\r\n   //alert(\"[verifyClose] Form name is \" + vFormObj.name);\r\n \r\n   // Check the action.  If it's query or view mode, don't bother checking this form.\r\n   var vActionObj = vFormObj.elements.item(\"action\");\r\n   if (vActionObj != null) {\r\n    var vAction = vActionObj.value;\r\n    if (vAction!=null) {\r\n     //alert(\"Action: \" + vAction);\r\n     if (vAction==\"");
      out.print(UIScreenSection.ACTION_INSERT);
      out.write("\" ||\r\n         vAction==\"");
      out.print(UIScreenSection.ACTION_UPDATE);
      out.write("\" ||\r\n         vAction==\"");
      out.print(UIScreenSection.ACTION_UPDATE_SELECT);
      out.write("\") {\r\n \r\n      // This is an updateable form in an updateable mode. Check for changes.\r\n \r\n      // Look through all the objects in the form to see if there are any unsaved changes.\r\n      var vElemC = vFormObj.elements;\r\n      for (var vElemNbr = 0; vElemNbr ");
      out.write("< vElemC.length; vElemNbr++) {\r\n       var vElemObj = vElemC.item(vElemNbr);\r\n \r\n       // Find out if this is the \"add\" or \"delete\" select object that appears on a \"select\" type screen section.\r\n       //alert(\"[window.onbeforeunload] Object name: \" + vElemObj.name);\r\n       if (vElemObj.name.indexOf(\"DBSel\")>=0) {\r\n        // This is the add or delete select object.  See if there are any items in it.  If so, it means\r\n        // the user has made changes.\r\n        if (vElemObj.length > 0) {\r\n         // Changes have been made.  Trigger the response window.\r\n         return \"IF YOU CLICK OK, YOUR CHANGES WILL BE LOST.\";\r\n        } else {\r\n         // No changes in this add or delete select object.\r\n        }\r\n       } else {\r\n        // Object is not the add or delete select object.\");\r\n        // See if this element is an original value field.\r\n        var vOrigPrefix = \"");
      out.print(UIWebUtility.HTML_NAME_PREFIX_ORIGINAL);
      out.write("\";\r\n        if (vElemObj.name.indexOf(vOrigPrefix)==0) {\r\n         // This is an original value field.  Compare its value to the current value field.\r\n         var vOrigElemObj = vElemObj;\r\n         var vOrigElemName = vOrigElemObj.name;\r\n         var vCurElemName = vOrigElemName.substring(vOrigPrefix.length, vOrigElemName.length);\r\n         var vCurElemObj = vElemC.item(vCurElemName);\r\n         var vCurElemTagName = vCurElemObj.tagName;\r\n         var vCurElemType = vCurElemObj.type;\r\n         if (vCurElemObj!=null) {\r\n          // Got the current field. Compare the values.\r\n          var vCurValue;\r\n          if (vCurElemTagName==\"INPUT\" && vCurElemType==\"checkbox\") {\r\n           // This is a check box.  Use special processing to get current value.\r\n           vCurValue = vCurElemObj.checked ? \"Y\" : \"N\";\r\n          } else {\r\n           // Not a check box.\r\n           vCurValue = vCurElemObj.value;\r\n          }\r\n          var vOrigValue = vOrigElemObj.value;\r\n          if (vCurValue != vOrigValue) {\r\n           // This field was changed.  Trigger the response window.\r\n");
      out.write("    //       alert('Field ' + vCurElemName + ' changed.');\r\n    //       alert('Original Value: ' + vOrigValue);\r\n    //       alert('Current Value: ' + vCurValue);\r\n           return \"IF YOU CLICK OK, YOUR CHANGES WILL BE LOST.\";\r\n          }\r\n         }\r\n        }\r\n       }\r\n      }\r\n     }\r\n    }\r\n   }\r\n  }\r\n }\r\n");
      out.write("</SCRIPT>\r\n\r\n");
      out.write("<!-- onBeforeUnload.jsp - End -->\r\n\r\n\r\n");
      out.write("\r\n\r\n");
      out.write("<script>\r\n// Title: Timestamp picker\r\n// Description: See the demo at url\r\n// URL: http://us.geocities.com/tspicker/\r\n// Script featured on: http://javascriptkit.com/script/script2/timestamp.shtml\r\n// Version: 1.0\r\n// Date: 12-05-2001 (mm-dd-yyyy)\r\n// Author: Denis Gritcyuk ");
      out.write("<denis@softcomplex.com>; ");
      out.write("<tspicker@yahoo.com>\r\n// Notes: Permission given to use this script in any kind of applications if\r\n//    header lines are left unchanged. Feel free to contact the author\r\n//    for feature requests and/or donations\r\n\r\nfunction setCalendarHasFocus(aFormObj, aHasFocus) {\r\n\t// Set hidden variable to show that a popup calendar is about to\r\n\t// be displayed.  This variable will be tested in the onBeforeUnload\r\n\t// handling to avoid popping up a confimation prompt.\r\n\talert(\"setCalendarHasFocus start - \" + aHasFocus);\r\n\tvar vCalendarHasFocusObj = aFormObj.elements.item(\"calendarHasFocus\");\r\n\tif (vCalendarHasFocusObj == null) {\r\n\t\t//alert(\"Did not find calendarHasFocus hidden field\");\r\n\t} else {\r\n\t\t//alert(\"Found calendarHasFocus hidden field\");\r\n\t\tif (aHasFocus) {\r\n\t\t\t//alert(\"Setting calendarHasFocus to true\");\r\n\t\t\tvCalendarHasFocusObj.value = \"true\";\r\n\t\t} else {\r\n\t\t\t//alert(\"Setting calendarHasFocus to false\");\r\n\t\t\tvCalendarHasFocusObj.value = \"false\";\r\n\t\t}\r\n\t}\r\n\treturn false;\r\n}\r\n\r\nfunction show_calendar(str_target, str_datetime, isDateTime) {\r\n");
      out.write("//\talert(\"show_calendar start\");\r\n\tvar arr_months = [\"January\", \"February\", \"March\", \"April\", \"May\", \"June\",\r\n\t\t\"July\", \"August\", \"September\", \"October\", \"November\", \"December\"];\r\n\tvar week_days = [\"Su\", \"Mo\", \"Tu\", \"We\", \"Th\", \"Fr\", \"Sa\"];\r\n\tvar n_weekstart = 1; // day week starts from (normally 0 or 1)\r\n\r\n\tvar dt_datetime = (str_datetime == null || str_datetime ==\"\" ?  new Date() :  str2datetime(str_datetime) );\r\n\tvar dt_prev_month = new Date(dt_datetime);\r\n\tdt_prev_month.setMonth(dt_datetime.getMonth()-1);\r\n\tvar dt_next_month = new Date(dt_datetime);\r\n\tdt_next_month.setMonth(dt_datetime.getMonth()+1);\r\n\tvar dt_firstday = new Date(dt_datetime);\r\n\tdt_firstday.setDate(1);\r\n\tdt_firstday.setDate(1-(7+dt_firstday.getDay()-n_weekstart)%7);\r\n\tvar dt_lastday = new Date(dt_next_month);\r\n\tdt_lastday.setDate(0);\r\n\t\r\n\t// html generation (feel free to tune it for your particular application)\r\n\t// print calendar header\r\n\tvar str_buffer = new String (\r\n\t\t\"");
      out.write("<html>\\n\"+\r\n\t\t\" ");
      out.write("<head>\\n\"+\r\n\t\t\"  ");
      out.write("<title>Calendar");
      out.write("</title>\\n\"+\r\n\t\t\" ");
      out.write("</head>\\n\"+\r\n\t\t\" ");
      out.write("<body bgcolor=\\\"White\\\">\\n\"+\r\n\t\t\"  ");
      out.write("<table class=\\\"clsOTable\\\" cellspacing=\\\"0\\\" border=\\\"0\\\" width=\\\"100%\\\">\\n\" +\r\n\t\t\"   ");
      out.write("<tr>\\n\" +\r\n\t\t\"    ");
      out.write("<td bgcolor=\\\"#4682B4\\\">\\n\" +\r\n\t\t\"     ");
      out.write("<table cellspacing=\\\"1\\\" cellpadding=\\\"3\\\" border=\\\"0\\\" width=\\\"100%\\\">\\n\" +\r\n\t\t\"      ");
      out.write("<tr>\\n\" +\r\n\t\t\"       ");
      out.write("<td bgcolor=\\\"#4682B4\\\">\\n\" +\r\n\t\t\"        ");
      out.write("<a href=\\\"javascript:window.opener.show_calendar('\"+\r\n\t\t           str_target + \"', '\" + dt2dtstr(dt_prev_month)+\"'+' ' +document.cal.time.value);\\\">\" +\r\n\t\t\"         ");
      out.write("<img src=\\\"/sfaimages/prev.gif\\\" width=\\\"16\\\" height=\\\"16\\\" border=\\\"0\\\"\" +\r\n\t\t\"           alt=\\\"previous month\\\">\\n\" +\r\n\t\t\"        ");
      out.write("</a>\\n\" +\r\n\t\t\"       ");
      out.write("</td>\\n\" +\r\n\t\t\"       ");
      out.write("<td bgcolor=\\\"#4682B4\\\" colspan=\\\"5\\\">\\n\" +\r\n\t\t\"        ");
      out.write("<font color=\\\"white\\\" face=\\\"tahoma, verdana\\\" size=\\\"2\\\">\\n\" +\r\n\t\t\"         \" + arr_months[dt_datetime.getMonth()] + \" \" + dt_datetime.getFullYear() + \"\\n\" +\r\n\t\t\"        ");
      out.write("</font>\\n\" +\r\n\t\t\"       ");
      out.write("</td>\\n\" +\r\n\t\t\"       ");
      out.write("<td bgcolor=\\\"#4682B4\\\" align=\\\"right\\\">\\n\" +\r\n\t\t\"        ");
      out.write("<a href=\\\"javascript:window.opener.show_calendar('\" +\r\n\t\t           str_target+\"', '\"+dt2dtstr(dt_next_month)+\"'+' ' +document.cal.time.value);\\\">\\n\" +\r\n\t\t\"         ");
      out.write("<img src=\\\"/sfaimages/next.gif\\\" width=\\\"16\\\" height=\\\"16\\\" border=\\\"0\\\"\" +\r\n\t\t\"           alt=\\\"next month\\\">\\n\" +\r\n\t\t\"        ");
      out.write("</a>\\n\" +\r\n\t\t\"       ");
      out.write("</td>\\n\" +\r\n\t\t\"      ");
      out.write("</tr>\\n\"\r\n\t);\r\n\r\n\tvar dt_current_day = new Date(dt_firstday);\r\n\t// print weekdays titles\r\n\tstr_buffer += \"      ");
      out.write("<tr>\\n\";\r\n\tfor (var n=0; n");
      out.write("<7; n++)\r\n\t\tstr_buffer += \"       ");
      out.write("<td bgcolor=\\\"#87CEFA\\\">\\n\" +\r\n\t\t\"       ");
      out.write("<font color=\\\"white\\\" face=\\\"tahoma, verdana\\\" size=\\\"2\\\">\\n\" +\r\n\t\t\"        \" + week_days[(n_weekstart+n)%7] + \"\\n\" +\r\n\t\t\"       ");
      out.write("</font>");
      out.write("</td>\\n\";\r\n\t// print calendar table\r\n\tstr_buffer += \"      ");
      out.write("</tr>\\n\";\r\n\twhile (dt_current_day.getMonth() == dt_datetime.getMonth() ||\r\n\t\tdt_current_day.getMonth() == dt_firstday.getMonth()) {\r\n\t\t// print row heder\r\n\t\tstr_buffer += \"      ");
      out.write("<tr>\\n\";\r\n\t\tfor (var n_current_wday=0; n_current_wday");
      out.write("<7; n_current_wday++) {\r\n\t\t\t\tif (dt_current_day.getDate() == dt_datetime.getDate() &&\r\n\t\t\t\t\tdt_current_day.getMonth() == dt_datetime.getMonth())\r\n\t\t\t\t\t// print current date\r\n\t\t\t\t\tstr_buffer += \"       ");
      out.write("<td bgcolor=\\\"#FFB6C1\\\" align=\\\"right\\\">\\n\";\r\n\t\t\t\telse if (dt_current_day.getDay() == 0 || dt_current_day.getDay() == 6)\r\n\t\t\t\t\t// weekend days\r\n\t\t\t\t\tstr_buffer += \"       ");
      out.write("<td bgcolor=\\\"#DBEAF5\\\" align=\\\"right\\\">\\n\";\r\n\t\t\t\telse\r\n\t\t\t\t\t// print working days of current month\r\n\t\t\t\t\tstr_buffer += \"       ");
      out.write("<td bgcolor=\\\"white\\\" align=\\\"right\\\">\\n\";\r\n\r\n\t\t\t\tif (isDateTime == \"1\" )\r\n\t\t\t\t\tstr_buffer += \"        ");
      out.write("<a href=\\\"javascript:window.opener.\" + str_target +\r\n\t\t\t\t\t\t\".value='\"+dt2dtstr(dt_current_day)+\"'+' ' +document.cal.time.value;window.close();\\\">\\n\";\r\n\t\t\t\telse\r\n\t\t\t\t\tstr_buffer += \"        ");
      out.write("<a href=\\\"javascript:window.opener.\" + str_target +\r\n\t\t\t\t\t\t\".value='\"+dt2dtstr(dt_current_day)+\"';window.close();\\\">\\n\";\r\n\t\t\t\t\t\r\n\t\t\t\tif (dt_current_day.getMonth() == dt_datetime.getMonth())\r\n\t\t\t\t\t// print days of current month\r\n\t\t\t\t\tstr_buffer += \"         ");
      out.write("<font color=\\\"black\\\" face=\\\"tahoma, verdana\\\" size=\\\"2\\\">\\n\";\r\n\t\t\t\telse \r\n\t\t\t\t\t// print days of other months\r\n\t\t\t\t\tstr_buffer += \"         ");
      out.write("<font color=\\\"gray\\\" face=\\\"tahoma, verdana\\\" size=\\\"2\\\">\\n\";\r\n\t\t\t\t\t\r\n\t\t\t\tstr_buffer += \"          \" + dt_current_day.getDate() + \"\\n\" +\r\n\t\t\t\t\"         ");
      out.write("</font>\\n\" +\r\n\t\t\t\t\"        ");
      out.write("</a>\\n\" +\r\n\t\t\t\t\"       ");
      out.write("</td>\\n\";\r\n\t\t\t\tdt_current_day.setDate(dt_current_day.getDate()+1);\r\n\t\t}\r\n\t\t// print row footer\r\n\t\tstr_buffer += \"      ");
      out.write("</tr>\\n\";\r\n\t}\r\n\t// print calendar footer\r\n\tstr_buffer +=\r\n\t\t\"      ");
      out.write("<form name=\\\"cal\\\">\\n\" +\r\n\t\t\"       ");
      out.write("<tr>\\n\" +\r\n\t\t\"        ");
      out.write("<td colspan=\\\"7\\\" bgcolor=\\\"#87CEFA\\\">\\n\" +\r\n\t\t\"         ");
      out.write("<font color=\\\"White\\\" face=\\\"tahoma, verdana\\\" size=\\\"2\\\">\\n\" +\r\n\t\t\"          Time:\\n\" +\r\n\t\t\"          ");
      out.write("<input type=\\\"text\\\" name=\\\"time\\\" value=\\\"\" + dt2tmstr(dt_datetime) +\r\n\t\t\"\\\" size=\\\"8\\\" maxlength=\\\"8\\\">\\n\" +\r\n\t\t\"         ");
      out.write("</font>\\n\" +\r\n\t\t\"        ");
      out.write("</td>\\n\" +\r\n\t\t\"       ");
      out.write("</tr>\\n\" +\r\n\t\t\"      ");
      out.write("</form>\\n\" +\r\n\t\t\"     ");
      out.write("</table>\\n\" +\r\n\t\t\"    ");
      out.write("</tr>\\n\" +\r\n\t\t\"   ");
      out.write("</td>\\n\" +\r\n\t\t\"  ");
      out.write("</table>\\n\" +\r\n\t\t\" ");
      out.write("</body>\\n\" +\r\n\t\t\"");
      out.write("</html>\\n\";\r\n\r\n\t//alert(\"Fixin to open window\");\r\n\tvar vWinCal = window.open(\"\", \"Calendar\", \r\n\t\t\"width=200,height=250,status=no,resizable=yes,top=200,left=200\");\r\n\t//alert(\"Fixin to set window opener to self\");\r\n\tvWinCal.opener = self;\r\n\tvar calc_doc = vWinCal.document;\r\n\t//alert(\"Fixin to write str_buffer\");\r\n\tcalc_doc.write (str_buffer);\r\n\tcalc_doc.close();\r\n}\r\n// datetime parsing and formatting routimes. modify them if you wish other datetime format\r\nfunction str2datetime (str_datetime) {\r\n\tvar re_date = /^(\\d+)\\/(\\d+)\\/(\\d+)\\s+(\\d+)\\:(\\d+)\\:(\\d+)$/;\r\n\tif (!re_date.exec(str_datetime))\r\n\t\treturn str2date(str_datetime)\r\n\treturn (new Date (RegExp.$3, RegExp.$1-1, RegExp.$2, RegExp.$4, RegExp.$5, RegExp.$6));\r\n}\r\nfunction str2date (str_date) {\r\n\tvar re_date = /^(\\d+)\\/(\\d+)\\/(\\d+)$/;\r\n\tif (!re_date.exec(str_date))\r\n\t\treturn alert(\"Invalid Date format: \"+ str_date);\r\n\treturn (new Date (RegExp.$3, RegExp.$1-1, RegExp.$2, 0, 0, 0));\r\n}\r\n\r\nfunction dt2dtstr (dt_datetime) {\r\n\treturn (new String (\r\n\t\t\t(dt_datetime.getMonth()+1)+\"/\"+dt_datetime.getDate()+\"/\"+dt_datetime.getFullYear()));\r\n");
      out.write("}\r\nfunction dt2tmstr (dt_datetime) {\r\n\treturn (new String (\r\n\t\t\tdt_datetime.getHours()+\":\"+dt_datetime.getMinutes()+\":\"+dt_datetime.getSeconds()));\r\n}\r\n\r\n");
      out.write("</script>\r\n");
      out.write("\r\n\r\n");
      out.write("\r\n");
      com.sourcetap.sfa.lead.LeadEventProcessor leadEventProcessor = null;
      synchronized (application) {
        leadEventProcessor = (com.sourcetap.sfa.lead.LeadEventProcessor) pageContext.getAttribute("leadEventProcessor", PageContext.APPLICATION_SCOPE);
        if (leadEventProcessor == null){
          try {
            leadEventProcessor = (com.sourcetap.sfa.lead.LeadEventProcessor) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "com.sourcetap.sfa.lead.LeadEventProcessor");
          } catch (ClassNotFoundException exc) {
            throw new InstantiationException(exc.getMessage());
          } catch (Exception exc) {
            throw new ServletException("Cannot create bean of class " + "com.sourcetap.sfa.lead.LeadEventProcessor", exc);
          }
          pageContext.setAttribute("leadEventProcessor", leadEventProcessor, PageContext.APPLICATION_SCOPE);
        }
      }
      out.write("\r\n");
      com.sourcetap.sfa.event.GenericImportEventProcessor importEventProcessor = null;
      synchronized (application) {
        importEventProcessor = (com.sourcetap.sfa.event.GenericImportEventProcessor) pageContext.getAttribute("importEventProcessor", PageContext.APPLICATION_SCOPE);
        if (importEventProcessor == null){
          try {
            importEventProcessor = (com.sourcetap.sfa.event.GenericImportEventProcessor) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "com.sourcetap.sfa.event.GenericImportEventProcessor");
          } catch (ClassNotFoundException exc) {
            throw new InstantiationException(exc.getMessage());
          } catch (Exception exc) {
            throw new ServletException("Cannot create bean of class " + "com.sourcetap.sfa.event.GenericImportEventProcessor", exc);
          }
          pageContext.setAttribute("importEventProcessor", importEventProcessor, PageContext.APPLICATION_SCOPE);
        }
      }
      out.write("\r\n\r\n");

  String screen = "LEAD";
  String screenSection = "LeadHeader";
  String entityName = "Lead";
  CsvConverter csvConverter = null;
  String action = "start"; // default action

  if ( request.getParameter("action") != null )
  {
    action = request.getParameter("action");
  }

    try{

    if(action.equals("start")){
   
      ModelEntity entity = delegator.getModelEntity(entityName);

       UIWebScreenSection uiWebScreenSection = importEventProcessor.getUiWebScreenSection(userInfo, screen, screenSection, delegator, uiCache);        
      List fields = uiWebScreenSection.getDisplayFields(uiCache);
     
      int numFields = fields.size();     
     

      out.write("\r\n\t\t\t");
      out.write("<table width=\"100%\" class=\"freeFormSectionDisplayTable\">");
      out.write("<tr>");
      out.write("<td valign=\"top\">\r\n\t\t\t");
      out.write("<tr>");
      out.write("<td>");
      out.write("<center>");
      out.write("<b>Choose Fields to include in Form.");
      out.write("</b>");
      out.write("</center>");
      out.write("</td>");
      out.write("</tr>\r\n\t\t\t");
      out.write("<tr>");
      out.write("<td>\r\n\t\t\t      ");
      out.write("<!-- title table -->\r\n\t\t\t\t\t  ");
      out.write("<center>");
      out.write("<table class=\"freeFormSectionDisplayTable\" cellspacing=\"0\" cellpadding=\"2\" id='queryListTable'>\r\n\t\t\t\t\t  ");
      out.write("<form method=\"post\" action=\"/sfa/control/leadCaptureSetup\">\r\n\t\t\t\t\t\t   ");
      out.write("<input type=hidden name=action value=\"generate\">\r\n\t\t\t\t\t\t   ");
      out.write("<input type=\"hidden\" name=\"numFields\" value=\"");
      out.print(numFields);
      out.write("\">\r\n\t\t\t\t\t\t\t");
      out.write("<input type=hidden id=queryListMaxRows name=queryListMaxRows value=4>\r\n \t\t\t\t\t\t");
      out.write("<tr>");
      out.write("<td class=freeFormSectionLabel>");
      out.write("<center>Field");
      out.write("<center>");
      out.write("</td>\r\n\t\t\t\t\t\t    ");
      out.write("<td class=freeFormSectionLabel>");
      out.write("<center>Label");
      out.write("</center>");
      out.write("</td>\r\n\t\t\t\t\t\t");
      out.write("</tr>\r\n");
     

      Iterator fieldIter = fields.iterator();
      StringBuffer fieldNameOptions = new StringBuffer(200);
     
      while (fieldIter.hasNext())
      {
     
           UIFieldInfo fieldInfo = (UIFieldInfo)fieldIter.next();
        //     if ( fieldInfo.getIsVisible() && !fieldInfo.getIsReadOnly() )

            String fieldName = UIWebUtility.getHtmlName(screenSection, fieldInfo, 0);
           String displayName = fieldInfo.getDisplayLabel();
             
        if ( fieldName.equals("lastUpdatedStamp") || fieldName.equals("lastUpdatedTxStamp") ||
             fieldName.equals("createdStamp") || fieldName.equals("createdTxStamp") )
             continue;

        String htmlName = fieldName;
        String displayObjectId = fieldInfo.getDisplayObjectId();
        String displayTypeId = "TEXT"; //fieldInfo.getDisplayTypeId();
        String attributeId = fieldInfo.getAttributeId();
        String displayLabel = fieldInfo.getDisplayLabel();
        String optValue = htmlName + ";" + attributeId + ";" + displayTypeId + ";" + displayObjectId + ";" + displayLabel;
        fieldNameOptions.append("<option value='" + optValue + "'>" + displayLabel + "</option>")
      }
     
      for ( int i=1; i < 5; i++)
      {
        out.write("<tr id=queryListRow" + i + "><td><select name=queryListField" + i + ">" +  fieldNameOptions.toString() + "</select></td>\n");
        out.write("  <td><input name=queryListLabel" + i + " size=30></td>\n");
        out.write("  <td><img src=/sfaimages/remove.gif alt=Del onClick=delConditionRow(" + i + ")>\n");
        out.write("      <img src=/sfaimages/add.gif alt=Add onClick=addConditionRow(" + i + ")></td>\n");
        out.write("</tr>");   
      }


      out.write("\r\n\t\t\t\t");
      out.write("</table>");
      out.write("</center>\r\n\t\t\t\t");
      out.write("</td>");
      out.write("</tr>\r\n\t\t\t\t");
      out.write("<tr>");
      out.write("<td>");
      out.write("<center>\r\n\t\t\t\t");
      out.write("<table>");
      out.write("<tr>");
      out.write("<td>URL to Redirect to on Success:");
      out.write("</td>");
      out.write("<td>");
      out.write("<input name=\"onSuccessURL\" size=80>");
      out.write("</td>");
      out.write("</tr>\r\n\t\t\t\t       ");
      out.write("<tr>");
      out.write("<td>URL to Redirect to on Error:");
      out.write("</td>");
      out.write("<td>");
      out.write("<input name=\"onErrorURL\" size=80>");
      out.write("</td>");
      out.write("</tr>\t\r\n\t\t\t\t");
      out.write("</table>\t\t\t\r\n\t\t\t\t");
      out.write("<tr>");
      out.write("<td>");
      out.write("<center>");
      out.write("<input type=submit value=\"Generate HTML\">");
      out.write("</center>");
      out.write("</td>");
      out.write("</tr>\r\n\t\t\t\t");
      out.write("</form>\r\n\t\t\t");
      out.write("</table>\r\n\t\t\t\r\n\t\t\t");
      out.write("<script type='text/javascript'>\r\n\t\t\tfunction addConditionRow(i) {\r\n\t\t\t\tvar tab1=document.getElementById('queryListTable')\r\n\t\t\t\tif ( tab1 ) {\r\n\t\t\t\t\tvar numRows = tab1.rows.length\r\n\t\t\t\t\tvar maxRows = 30\r\n\t\t\t\t\tif ( numRows > maxRows )\r\n\t\t\t\t\t\talert(\"Can't have more than 10 fields\");\r\n\t\t\t\t\telse {\r\n\t\t\t\t\t\tvar x = tab1.insertRow(numRows)\r\n\t\t\t\t\t\tvar maxRows = document.getElementById('queryListMaxRows')\r\n\t\t\t\t\t\tvar newRow = maxRows.value -  -1\r\n\t\t\t\t\t\tmaxRows.value = newRow\r\n\t\t\t\t\t\tx.id = \"queryListRow\" + newRow\r\n\t\t\t\t\t\tvar c1=x.insertCell(0)\r\n\t\t\t\t\t\tvar c2=x.insertCell(1)\r\n\t\t\t\t\t\tvar c3=x.insertCell(2)\r\n\t\t\t\t\t\tc1.innerHTML=\"");
      out.write("<select name=queryListField\" + newRow + \">");
      out.print(fieldNameOptions.toString());
      out.write("</select>\"\r\n\t\t\t\t\t\tc2.innerHTML=\"");
      out.write("<input name=queryListLabel\" + newRow + \" size=30>\"\r\n\t\t\t\t\t\tc3.innerHTML=\"");
      out.write("<img src=/sfaimages/remove.gif alt=Del onClick=delConditionRow(\" + newRow + \")>\" + \" ");
      out.write("<img src=/sfaimages/add.gif alt=Add onClick=addConditionRow(\" + newRow + \")>\"\r\n\t\t\t\t\t}\r\n\t\t\t\t\tfixSize()\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tfunction delConditionRow(i)\r\n\t\t\t{\r\n\t\t\t\tvar row1 = document.getElementById('queryListRow' + i)\r\n\t\t\t\tvar tab = document.getElementById('queryListTable')\r\n\t\t\t\tvar rows = tab.rows\r\n\t\t\t\tif ( rows.length == 2 ) {\r\n\t\t\t\t\tevent.returnValue = false\r\n\t\t\t\t\treturn;\r\n\t\t\t\t}\r\n\t\t\t\tfor ( i=0; i ");
      out.write("< rows.length; i++ ) {\r\n\t\t\t\t\trow = rows[i];\r\n\t\t\t\t\tif ( row.id == row1.id) {\r\n\t\t\t\t\t\ttab.deleteRow(i);\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tfixSize()\r\n\t\t\t}\r\n\t\t\t");
      out.write("</script>\r\n\t\t\t\r\n");


    } else if(action.equals("generate")) {

      StringBuffer formHTML = new StringBuffer(1000);
      String successURL = UtilFormatOut.checkNull(request.getParameter("onSuccessURL"));
      String errorURL = UtilFormatOut.checkNull(request.getParameter("onErrorURL"));

      String path = request.getRequestURL().toString();
      int lastSlash = path.lastIndexOf('/');
      path = path.substring(0, lastSlash);
      formHTML.append("<form action=" + path + "/leadCapture target='_self' method=post>\n");
      formHTML.append("<input type=hidden name=action value='save'>\n");
      formHTML.append("<input type=hidden name=cid value='" + userInfo.getAccountId() + "'>\n");
      formHTML.append("<input type=hidden name=uid value='" + userInfo.getPartyId() + "'>\n");
      formHTML.append("<input type=hidden name=onSuccess value='" + successURL + "'>\n");
      formHTML.append("<input type=hidden name=onError value='" + errorURL+ "'>\n");
      formHTML.append("<table>\n");
           
      String queryListMaxRows = request.getParameter("queryListMaxRows");
View Full Code Here

        long requestStartTime = System.currentTimeMillis();
        HttpSession session = request.getSession();

        GenericValue userLogin = (GenericValue) session.getAttribute("userLogin");
    UserInfo userInfo  = (UserInfo) session.getAttribute("userInfo");
        //Debug.log("Cert Chain: " + request.getAttribute("javax.servlet.request.X509Certificate"), module);

        // workaraound if we are in the root webapp
        String webappName = UtilHttp.getApplicationName(request);

        String rname = "";
        if (request.getPathInfo() != null) {
            rname = request.getPathInfo().substring(1);
        }
        if (rname.indexOf('/') > 0) {
            rname = rname.substring(0, rname.indexOf('/'));
        }

        UtilTimer timer = null;
        if (Debug.timingOn()) {
            timer = new UtilTimer();
            timer.setLog(true);
            timer.timerString("[" + rname + "] Servlet Starting, doing setup", module);
        }
       
        // Setup the CONTROL_PATH for JSP dispatching.
        request.setAttribute("_CONTROL_PATH_", request.getContextPath() + request.getServletPath());
        if (Debug.verboseOn())
            Debug.logVerbose("Control Path: " + request.getAttribute("_CONTROL_PATH_"), module);

        // for convenience, and necessity with event handlers, make security and delegator available in the request:
        // try to get it from the session first so that we can have a delegator/dispatcher/security for a certain user if desired
        GenericDelegator delegator = null;
        String delegatorName = (String) session.getAttribute("delegatorName");
        if (UtilValidate.isNotEmpty(delegatorName)) {
            delegator = GenericDelegator.getGenericDelegator(delegatorName);
        }
        if (delegator == null) {
            delegator = (GenericDelegator) getServletContext().getAttribute("delegator");
        }
        if (delegator == null) {
            Debug.logError("[ControlServlet] ERROR: delegator not found in ServletContext", module);
        } else {
            request.setAttribute("delegator", delegator);
            // always put this in the session too so that session events can use the delegator
            session.setAttribute("delegatorName", delegator.getDelegatorName());
        }

        // display details on the servlet objects
        if (Debug.verboseOn()) {
            logRequestInfo(request);
        }

    int fyStartMonth = CalendarUtil.getFiscalYearStartMonth( delegator, userInfo );
        if (Debug.timingOn()) timer.timerString("[" + rname + "] Setup done, doing Event(s) and View(s)", module);

    try {
    String monthLabel[] = {"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
    BarChartProperties properties = new BarChartProperties();
    AxisProperties axisProperties = new AxisProperties();
    axisProperties.setScaleFont( new Font( "Arial", Font.BOLD, 12 ) );
    axisProperties.setAxisTitleFont( new Font( "Arial", Font.BOLD, 12 ) );
    axisProperties.setYAxisUseDollarSigns(true);

    LineChartProperties lineChartProperties = new LineChartProperties(new BasicStroke());


    Paint[] paints= { new Color(100,150,100) };
    int width = 330;
    int height = 216;
    String xAxisTitle = " ";
    String yAxisTitle = " ";

    ArrayList xAxisLabels = new ArrayList();
    ArrayList legendLabels = new ArrayList();

    if(request.getParameter("report").equals("salesForQuarter")){
    double data[] = new double[3];
    Calendar cal = Calendar.getInstance();

    int month = cal.get(Calendar.MONTH) + 1;
    int year = cal.get(Calendar.YEAR);
    int quarterNumbers[] = CalendarUtil.getQuarterMonthNumbers(month, fyStartMonth);

    ArrayList list = new ArrayList();
    list.add(new EntityExpr("ownerId", EntityOperator.EQUALS, userInfo.getPartyId()));
    list.add(new EntityExpr("dealStatusId", EntityOperator.EQUALS, "10"));
    list.add(new EntityExpr("actualCloseDate", EntityOperator.LESS_THAN_EQUAL_TO, new java.sql.Date( CalendarUtil.getMaximumQuarterDate(cal.get(Calendar.MONTH) + 1, cal.get(Calendar.YEAR), fyStartMonth).getTime())));
    list.add(new EntityExpr("actualCloseDate", EntityOperator.GREATER_THAN_EQUAL_TO, new java.sql.Date( CalendarUtil.getMinimumQuarterDate(cal.get(Calendar.MONTH) + 1, cal.get(Calendar.YEAR), fyStartMonth).getTime())));

    ArrayList order = new ArrayList();
    order.add("actualCloseDate");

    java.util.List dealList = delegator.findByAnd("Deal", list, order);
    GenericValue dealValues[] = (GenericValue[])dealList.toArray(new GenericValue[0]);
    GenericValue dealValue = null;

    String months[] = CalendarUtil.getQuarterMonthNames(cal.get(Calendar.MONTH) + 1, fyStartMonth);
    for(int iz=0;iz<months.length;iz++){
      xAxisLabels.add((String)months[iz]);
    }

    xAxisTitle = "Month";
    yAxisTitle = "Sales";

    legendLabels.add("Pipeline for Quarter");

    for(int iz=0;iz<dealValues.length;iz++) {
      dealValue = dealValues[iz];
      Calendar calendar = Calendar.getInstance();
      calendar.setTime(dealValue.getDate("actualCloseDate"));

      if((calendar.get(Calendar.MONTH)+1)==quarterNumbers[0] && calendar.get(Calendar.YEAR)==year){
        data[0] = data[0] + dealValue.getDouble("amount").doubleValue();
      }
      if((calendar.get(Calendar.MONTH)+1)==quarterNumbers[1] && calendar.get(Calendar.YEAR)==year){
        data[1] = data[1] + dealValue.getDouble("amount").doubleValue();
      }
      if((calendar.get(Calendar.MONTH)+1)==quarterNumbers[2] && calendar.get(Calendar.YEAR)==year){
        data[2] = data[2] + dealValue.getDouble("amount").doubleValue();
      }
    }

      try {
      BarChart barChart = new BarChart(
        new SingleDataSet(
        data,
        (String[])legendLabels.toArray(new String[0]),
        (String[])xAxisLabels.toArray(new String[0]),
        paints,
        xAxisTitle,
        yAxisTitle ),
      false, properties, axisProperties, width, height );

      response.reset();
      response.setContentType("image/jpeg");
           
      barChart.exportJPG( response.getOutputStream(), 1.0f);
      response.getOutputStream().flush();
      } catch( Throwable throwable ) { throwable.printStackTrace();
      }
    }

    if(request.getParameter("report").equals("leadsForQuarter")){
    double data[] = new double[3];
    Calendar cal = Calendar.getInstance();

    int month = cal.get(Calendar.MONTH) + 1;
    int year = cal.get(Calendar.YEAR);
    int quarterNumbers[] = CalendarUtil.getQuarterMonthNumbers(month, fyStartMonth);

    ArrayList list = new ArrayList();
    list.add(new EntityExpr("leadOwnerId", EntityOperator.EQUALS, userInfo.getPartyId()));
    list.add(new EntityExpr("statusId", EntityOperator.EQUALS, "50"));
    list.add(new EntityExpr("convertedDate", EntityOperator.LESS_THAN_EQUAL_TO, new java.sql.Date( CalendarUtil.getMaximumQuarterDate(cal.get(Calendar.MONTH) + 1, cal.get(Calendar.YEAR), fyStartMonth).getTime())));
    list.add(new EntityExpr("convertedDate", EntityOperator.GREATER_THAN_EQUAL_TO, new java.sql.Date( CalendarUtil.getMinimumQuarterDate(cal.get(Calendar.MONTH) + 1, cal.get(Calendar.YEAR), fyStartMonth).getTime())));

    ArrayList order = new ArrayList();
    order.add("convertedDate");

    java.util.List dealList = delegator.findByAnd("Lead", list, order);
    GenericValue leadValues[] = (GenericValue[])dealList.toArray(new GenericValue[0]);
    GenericValue leadValue = null;

    String months[] = CalendarUtil.getQuarterMonthNames(cal.get(Calendar.MONTH) + 1, fyStartMonth);
    for(int iz=0;iz<months.length;iz++){
      xAxisLabels.add((String)months[iz]);
    }
    xAxisTitle = "Month";
    yAxisTitle = "Leads";

    legendLabels.add("Leads for Quarter");

    for(int iz=0;iz<leadValues.length;iz++) {
      leadValue = leadValues[iz];
      Calendar calendar = Calendar.getInstance();
      calendar.setTime(leadValue.getTimestamp("convertedDate"));

      if((calendar.get(Calendar.MONTH)+1)==quarterNumbers[0] && calendar.get(Calendar.YEAR)==year){
        data[0] = data[0] + 1;
      }
      if((calendar.get(Calendar.MONTH)+1)==quarterNumbers[1] && calendar.get(Calendar.YEAR)==year){
        data[1] = data[1] + 1;
      }
      if((calendar.get(Calendar.MONTH)+1)==quarterNumbers[2] && calendar.get(Calendar.YEAR)==year){
        data[2] = data[2] + 1;
      }
    }

    axisProperties.setYAxisUseDollarSigns(false);
    axisProperties.setYAxisRoundValuesToNearest(0);
//      axisProperties.setXAxisVerticalScaleFlag(true);

    try {
      BarChart barChart = new BarChart(
        new SingleDataSet(
        data,
        (String[])legendLabels.toArray(new String[0]),
        (String[])xAxisLabels.toArray(new String[0]),
        paints,
        xAxisTitle,
        yAxisTitle ),
      false, properties, axisProperties, width, height );

      response.reset();
      response.setContentType("image/jpeg");
      barChart.exportJPG( response.getOutputStream(), 1.0f);
      response.getOutputStream().flush();
      } catch( Throwable throwable ) { throwable.printStackTrace();
      }
    }

    if(request.getParameter("report").equals("forecastedForQuarter")){
    double data[] = new double[3];
    Calendar cal = Calendar.getInstance();

    int month = cal.get(Calendar.MONTH) + 1;
    int year = cal.get(Calendar.YEAR);
    int quarterNumbers[] = CalendarUtil.getQuarterMonthNumbers(month, fyStartMonth);

    ArrayList list = new ArrayList();
    list.add(new EntityExpr("ownerId", EntityOperator.EQUALS, userInfo.getPartyId()));
    list.add(new EntityExpr("projectedCloseDate", EntityOperator.LESS_THAN_EQUAL_TO, new java.sql.Date( CalendarUtil.getMaximumQuarterDate(cal.get(Calendar.MONTH) + 1, cal.get(Calendar.YEAR), fyStartMonth).getTime())));
    list.add(new EntityExpr("projectedCloseDate", EntityOperator.GREATER_THAN_EQUAL_TO, new java.sql.Date( CalendarUtil.getMinimumQuarterDate(cal.get(Calendar.MONTH) + 1, cal.get(Calendar.YEAR), fyStartMonth).getTime())));

    ArrayList order = new ArrayList();
    order.add("projectedCloseDate");
View Full Code Here

    //-------------------------------------------------------------------------
    public int processInsert(UserInfo userInfo, GenericDelegator delegator,
        DataMatrix dataMatrix) throws GenericEntityException {

        if (userInfo == null) {
            userInfo = new UserInfo();
        }

        int status = STATUS_CONTINUE;

        // If necessary, generate keys.
View Full Code Here

TOP

Related Classes of com.sourcetap.sfa.util.UserInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.