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 + '¶m_' + 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");
out.write(" \r\n");
String eventMsgReq = (String)request.getAttribute("EVENT_MESSAGE");
String errorMsgReqControl = (String)request.getAttribute("_ERROR_MESSAGE_");
String errorMsgReq = (String)request.getAttribute("ERROR_MESSAGE");
String errorMsgSes = (String)session.getAttribute("ERROR_MESSAGE");
if(errorMsgSes != null) session.removeAttribute("ERROR_MESSAGE");
if(errorMsgReq != null){
out.write("\r\n");
out.write("<br>\r\n");
out.write("<p>");
out.write("<font color=\"red\">");
out.print(errorMsgReq);
out.write("</font>");
out.write("</p>\r\n");
out.write("<br>\r\n");
} if(errorMsgSes != null){
out.write("\r\n");
out.write("<br>\r\n");
out.write("<p>");
out.write("<font color=\"red\">");
out.print(errorMsgSes);
out.write("</font>");
out.write("</p>\r\n");
out.write("<br>\r\n");
} if(errorMsgReqControl != null){
out.write("\r\n");
out.write("<br>\r\n");
out.write("<p>");
out.write("<font color=\"red\">");
out.print(errorMsgReqControl);
out.write("</font>");
out.write("</p>\r\n");
out.write("<br>\r\n");
} if(eventMsgReq != null){
out.write("\r\n");
out.write("<br>\r\n");
out.write("<p>");
out.write("<font color=\"blue\">");
out.print(eventMsgReq);
out.write("</font>");
out.write("</p>\r\n");
out.write("<br>\r\n");
}
out.write("\r\n\r\n");
out.write("\r\n\r\n");
String mimes = "";
out.write("\r\n\r\n");
//get the date information
String day = "";
String lsMonth = "";
String module = "frontPage";
Calendar selectedDayCalendar = Calendar.getInstance();
int month = (selectedDayCalendar.get(Calendar.MONTH) + 1);
int year = selectedDayCalendar.get(Calendar.YEAR);
int iday = selectedDayCalendar.get(Calendar.DATE);
//if the user has selcted a day
//get the activities for that day
if ( request.getParameter("day") != null ) {
day = request.getParameter("day");
iday = Long.valueOf(day).intValue();
selectedDayCalendar.set(year, month -1, iday, 0, 0 );
}
// the user has selected a month then use that month.
if ( request.getParameter("month") != null ) {
lsMonth = request.getParameter("month");
month = Long.valueOf(lsMonth).intValue();
selectedDayCalendar.set(year, month -1, iday, 0, 0 );
}
out.write("\r\n\r\n");
out.write("\r\n\r\n");
pageContext.setAttribute("PageName", "Main Page");
out.write("\r\n");
String loginUrl = controlPath + "/checkLogin/" + UtilFormatOut.checkNull((String)request.getAttribute("_CURRENT_VIEW_"));
out.write("\r\n");
pageContext.setAttribute("PageName", "Main Page");
out.write("\r\n\r\n");
if(session.getAttribute("partyId") != null && userLogin != null ) {
out.write("\r\n\r\n");
out.write("<SCRIPT FOR=\"window\" EVENT=\"onload\" LANGUAGE=\"JavaScript\">\r\n\t// Reload the menu to clear the menu items.\r\n\tparent.parent.menu.location.href = parent.parent.menu.location.href;\r\n");
out.write("</SCRIPT>\r\n\r\n");
int fyStartMonth = CalendarUtil.getFiscalYearStartMonth( delegator, userInfo );
// Find out if this is a leads user or leads admin. If so, going to display
// a special leads dashboard.
boolean leadDashBoard = false;
HashMap partyRoleFindMap = new HashMap();
partyRoleFindMap.put("partyId", userInfo.getPartyId());
try {
List partyRoleL = delegator.findByAnd("PartyRole", partyRoleFindMap);
Iterator partyRoleI = partyRoleL.iterator();
while (partyRoleI.hasNext()) {
GenericValue partyRoleGV = (GenericValue)partyRoleI.next();
String roleTypeId = partyRoleGV.getString("roleTypeId")==null ? "" : partyRoleGV.getString("roleTypeId");
if (roleTypeId.equals("SFA_LEADS_ADMIN") || roleTypeId.equals("SFA_LEADS_USER")) {
leadDashBoard = true;
}
}
} catch (Exception e) {
Debug.logWarning("Error retrieving user roles: " + e.getLocalizedMessage(), module);
}
Calendar cal = Calendar.getInstance();
cal.setTime(getHireDate(partyId, delegator));
int daysFromHire = CalendarUtil.differenceBetweenDates(cal, Calendar.getInstance(), Calendar.DAY_OF_YEAR);
//SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM/dd/YYYY");
Calendar allStart = Calendar.getInstance();
allStart.set(Calendar.YEAR, 1990);
allStart.set(Calendar.MONTH, Calendar.JANUARY);
allStart.set(Calendar.DAY_OF_MONTH, 1);
Calendar yearStart = Calendar.getInstance();
yearStart.set(Calendar.MONTH, Calendar.JANUARY);
yearStart.set(Calendar.DAY_OF_MONTH, 1);
Calendar yearEnd = Calendar.getInstance();
yearEnd.set(Calendar.MONTH, Calendar.DECEMBER);
yearEnd.set(Calendar.DAY_OF_MONTH, 31);
int yearLeadsConverted = calculateLeadsConverted(partyId, yearStart, yearEnd, delegator);
int yearLeadsAssigned = calculateLeadsAssigned(partyId, yearStart, yearEnd, delegator);
double yearLeadConversionRate = ((yearLeadsAssigned == 0) ? 0.0 : ((yearLeadsConverted * 100 ) / yearLeadsAssigned));
int allLeadsConverted = calculateLeadsConverted(partyId, allStart, yearEnd, delegator);
int allLeadsAssigned = calculateLeadsAssigned(partyId, allStart, yearEnd, delegator);
double allLeadConversionRate = ((allLeadsAssigned == 0) ? 0.0 : ((allLeadsConverted * 100 ) / allLeadsAssigned));
double quota = calculateYearlyQuota(partyId, delegator);
double actual = calculateYearlySales(partyId, delegator);
double quotaPercent = ((quota == 0) || (quota == 0.0) ? 0.0 : ((actual / quota) * 100));
double expenses = calculateYearlyExpenses(partyId, delegator);
out.write("\r\n\r\n");
out.write("<table width=100% class=\"freeFormSectionTitleTable\">\r\n ");
out.write("<tr>\r\n ");
out.write("<td colspan=3>\r\n ");
out.print(userInfo.getUserFullName());
out.write("'s Dashboard\r\n ");
out.write("<td>\r\n ");
out.write("</tr>\r\n");
out.write("</table>\r\n\r\n");
out.write("<!-- Table to separate the top half of the screen from the bottom half -->\r\n");