/*--------------------------------------------------------------------- Company : British Airways Application : Revenue Analysis Simplification Document : ras.js Author : Palladium Group, Inc. (Eric Thoennessen) Description : This file provides a number of JavaScript utility functions. Maintenance Note: If function names are changed or added, associated properties must be edited or new properties added to the 'RasResources.properties' file. Revisions: --------------------------------------------------------------------------------- 02/03/2007 (Nav Megh) JF6 changes - Adding action handler for BSP reports to ensure that currency conversion is only applied for REV measure --------------------------------------------------------------------------------- 07/03/2007 (Rick Passos) JF6 changes - Added functions to support advanced searching --------------------------------------------------------------------------------- 27/03/2007 (Rick Passos) JF6 changes - Changed message when no match found for advanced search to be consistent to that of standard search --------------------------------------------------------------------------------- 27/06/2007 (Nav Megh) JF6 changes CR15701: Adding new function submitOnDSwap to provide origin and destination swapping functionality. CR15702: replace LON with LONDON_(LON)search criteria so that searching for London is quick. Also replaced spaces with underscores (_) in the search criteria entered by users --------------------------------------------------------------------------------- 19/09/2007 (Vikas Sharma) HR-CR changes CRXXX: Adding dynamic Child dropdown update functionality. Function updateChildDropDown() added ------------------------------------------------------------------------------- 24/10/2007 (EW) Added currency text value change --------------------------------------------------------------------------------- 30/12/2008 (Vidya Ranjit) Switched the exchange dropdown to a "multiple dropdown" for HR and FWDBK . Included currency check for FWDBK tab also. Included code to switch "Booking Curves" reports on Fwdbk tab has been added --------------------------------------------------------------------------------- Jun - 09 (Vidya Ranjit) Included currency & exchange for current activity. --------------------------------------------------------------------------------- Jul - 09(Vidya Ranjit) Changes added to incorporate two views for the Agent and Customer Dashboard on HR for the performance graphs and associated grid. One view will show the 11 siblings associated with the month and the other view will show the children of the selected TimeSeries. --------------------------------------------------------------------------------- 25/11/2009 (Vidya Ranjit) Function added to display standard LH/SH settings for CRS and DMS cubes --------------------------------------------------------------------------------- 25/01/10(Vidya Ranjit) Haul info has been introduced into DMS and CRS cubes; hence ONDSwap function has to include the swap of Haul and baServed values in addition to Origin and Destination. ---------------------------------------------------------------------------------- Jul 11 (Vidya Ranjit) Changes for Revman Portal ---------------------------------------------------------------------------------- Jun 13 (Vidya Ranjit) 64 bit changes ---------------------------------------------------------------------------------- Oct 13 (Vidya Ranjit) Changes made for viewing on IPAD ----------------------------------------------------------------------------------- */ var FILTER_BODY_WIDTH = 300; // 280 NOTE: if it is necessary to modify the size of the filter body, be sure to update the // 'filter.width' property in the 'RasResources.properties' file. var FILTER_TAB_WIDTH = 23; /** * This function sets the position of the filter module in its open and closed states. */ function filter_position() { filter_open.style.left = document.body.clientWidth - FILTER_BODY_WIDTH; filter_open.style.width = FILTER_BODY_WIDTH; } /** * This function is responsible for reseting a search field. * * @param fieldId the ID of the search field to reset */ function resetSearchField(fieldId) { // NOTE: the form name 'RasForm' is defined in the 'struts-config.xml' file var inputFormElmt = "document.RasForm." + fieldId + "_display"; var hiddenFormElmt = "document.RasForm." + fieldId; eval(inputFormElmt + ".value = \"\""); eval(hiddenFormElmt + ".value = \"\""); } /** * This function is responsible for copying the text from the input form element * to the hidden form element. * * @param fieldId the ID of the search field to reset */ function copySearchFieldText(fieldId) { // NOTE: the form name 'RasForm' is defined in the 'struts-config.xml' file var inputFormElmt = "document.RasForm." + fieldId + "_display"; var hiddenFormElmt = "document.RasForm." + fieldId; eval(hiddenFormElmt + ".value = " + inputFormElmt + ".value"); } //(VIkas Sharma) HR-CR 19-09-2007: This function handles dynamic update of child dropdowns function updateChildDropDown(childDdwnId,parentDdwnId) { var req; var inputFormElmt = "document.RasForm." + childDdwnId; var inputValue = inputFormElmt + ".value"; var inputFormElmtv = "document.RasForm." + parentDdwnId; var inputValuev = inputFormElmtv + ".value"; var xmlResult; var parentvalue = eval(inputValuev); var childvalue = eval(inputValue); oSelect1 = document.getElementsByName(childDdwnId); eval(inputFormElmt + ".selectedIndex = 0"); var url = "updateChildDropDown?" +"childDdwnId=" + escape(childDdwnId)+ "&childvalue=" +escape(childvalue)+"&parentDdwnId=" + escape(parentDdwnId)+ "&parentvalue=" +escape(parentvalue); if (window.XMLHttpRequest) { req = new XMLHttpRequest; } else if (window.ActiveXObject) { req = new ActiveXObject("Microsoft.XMLHTTP"); } req.open("GET", url, true); req.onreadystatechange = function() { if (req.readyState==4 ) { xmlResult = req.responseText; if (xmlResult== "sessionTimedOut" ) { submitRasForm('submit'); } else { oSelect1[0].outerHTML= xmlResult ; } } } req.send(null); } /** * This function is responsible for handling form submission. * * @param action the action parameter value that gets submitted with other elements of the form */ function submitRasForm(action) { // NOTE: the form name 'RasForm' is defined in the 'struts-config.xml' file // NOTE: the 'action' form element is defined in the 'UrlUtil' class as a hidden field //VR(30/12/08) As extra measures are added to Fwdbk tab, the Booking Graphs also have to reflect that. //check if "Booking Curves" link is selected on Fwdbk tab . if so, set appropriate "Booking Curves" report //depending upon the measure selected. if((action == "submit") && (document.RasForm.crntTabId.value == "tab_fwdBk") && ((document.RasForm.reportId.value == "rpt_fwdBk_bookingCurves")||(document.RasForm.reportId.value == "rpt_fwdBk_bookingCurves2"))) { if( document.RasForm.ddwn_fwdBk_measure.value != "psj") { document.RasForm.reportId.value = "rpt_fwdBk_bookingCurves2"; //change value of report to 2 } if(document.RasForm.ddwn_fwdBk_measure.value == "psj") { // change value of report to 1 document.RasForm.reportId.value = "rpt_fwdBk_bookingCurves"; } } //VR(01/07/09) Two views for Agent and Corporate dashboard. if((action == "submit") && (document.RasForm.crntTabId.value == "tab_histRev") && ((document.RasForm.reportId.value == "rpt_histRev_customerAgent")||(document.RasForm.reportId.value == "rpt_histRev_customerAgent2"))) { if(document.RasForm.ddwn_histRev_period.value == "Historic_Months") { //display report2...i.e. view of 11 siblings document.RasForm.reportId.value = "rpt_histRev_customerAgent2" } else { //display children of the selected TimeSeries document.RasForm.reportId.value = "rpt_histRev_customerAgent" } } if((action == "submit") && (document.RasForm.crntTabId.value == "tab_histRev") && ((document.RasForm.reportId.value == "rpt_histRev_customerCorp")||(document.RasForm.reportId.value == "rpt_histRev_customerCorp2"))) { if(document.RasForm.ddwn_histRev_period.value == "Historic_Months") { //display report2...i.e. view of 11 siblings document.RasForm.reportId.value = "rpt_histRev_customerCorp2" } else { //display children of the selected TimeSeries document.RasForm.reportId.value = "rpt_histRev_customerCorp" } } if((action == "submit") && (document.RasForm.crntTabId.value == "tab_OnD") && ((document.RasForm.reportId.value == "rpt_OnD_customerAgent")||(document.RasForm.reportId.value == "rpt_OnD_customerAgent2"))) { // alert(document.RasForm.ddwn_OnD_timeSeries.value); // alert(document.RasForm.reportId.value); if(document.RasForm.ddwn_OnD_timeSeries.value == "Historic_Months") { //display report2...i.e. view of 11 siblings document.RasForm.reportId.value = "rpt_OnD_customerAgent2"; } else { //display children of the selected TimeSeries document.RasForm.reportId.value = "rpt_OnD_customerAgent"; } } /* if((action == "submit") && (document.RasForm.crntTabId.value == "tab_CB_Profile") && ((document.RasForm.reportId.value == "rpt_fwdBk_BIBkgCurvesTab3")||(document.RasForm.reportId.value == "rpt_fwdBk_BIBkgCurvesTab32"))) { if( document.RasForm.ddwn_fwdBk_measure.value != "psj") { document.RasForm.reportId.value = "rpt_fwdBk_BIBkgCurvesTab32"; //change value of report to 2 } if(document.RasForm.ddwn_fwdBk_measure.value == "psj") { //change value of report to 1 document.RasForm.reportId.value = "rpt_fwdBk_BIBkgCurvesTab3"; } }*/ // validate that the user has type in a view name //(VR): For Fwdbkg reports, check to see that currency conversion is not applied for PSJ reports if(action == "submit" && document.RasForm.crntTabId.value == "tab_fwdBk" && document.RasForm.ddwn_fwdBk_measure.value == "psj" && document.RasForm.ddwn_multiple_exchange.value == "BRX" && document.RasForm.ddwn_multiple_currency.value != "1") { //alert("Please Note when PSJ is selected, the Currency rate is defaulted to GB Pound."); document.RasForm.ddwn_multiple_currency.value = "1"; } //JF6 (NM): For BSP reports, check to see that currency conversion is only applied for REV reports /* if(action == "submit" && document.RasForm.crntTabId.value == "tab_BSP_MktShr" && document.RasForm.reportId.value != "rpt_bspMktshr_allMonths" && document.RasForm.ddwn_BSP_measures.value == "BSP_Tickets" && document.RasForm.ddwn_multiple_currency.value != "1") { alert("Please Note when Tickets is selected, the Currency rate is defaulted to GB Pound."); document.RasForm.ddwn_currency.value = "1"; } */ // if(action == "submit" && (document.RasForm.crntTabId.value == "tab_histRev" || document.RasForm.crntTabId.value == "tab_fwdBk" || // document.RasForm.crntTabId.value == "tab_bkgAct") && // document.RasForm.ddwn_multiple_exchange.value == "BRX") { // document.RasForm.ddwn_currency.value = document.RasForm.ddwn_multiple_currency.value; // } //(VR) Added the condition to check for FWDBK,CB tab also ; also changed the exchange dropdown to a multiple dropdown. //if(action == "submit" && ((document.RasForm.crntTabId.value == "tab_histRev") || (document.RasForm.crntTabId.value == "tab_fwdBk") || (document.RasForm.crntTabId.value == "tab_bkgAct")) && document.RasForm.ddwn_multiple_exchange.value == "OTX" && document.RasForm.ddwn_currency.value != "1") //{ // alert("Please Note when OTX Exchange Rate is selected,the Currency rate is defaulted to GB Pound."); // document.RasForm.ddwn_currency.value = "1"; //} if(action == "add" && document.RasForm.tf_view_name.value == "") { alert("Please enter a name for the view."); document.RasForm.tf_view_name.focus(); } else { document.RasForm.action.value = action; document.RasForm.submit(); } } /** * This function is responsible for handling the submission of a search request * * @param action the action parameter value that gets submitted with other elements of the form * @param searchFieldId the ID of the search field being searched on */ function submitSearch(action, searchFieldId) { // NOTE: the form name 'RasForm' is defined in the 'struts-config.xml' file // NOTE: the 'searchFieldId' form element is defined in the 'UrlUtil' class as a hidden field var inputFormElmt = "document.RasForm." + searchFieldId + "_display"; var hiddenFormElmt = "document.RasForm." + searchFieldId; // validate the user has typed in a search criteria if(eval(inputFormElmt + ".value") == "") { alert("Please enter a search criteria."); eval(inputFormElmt + ".focus()"); } else { eval(hiddenFormElmt + ".value = " + inputFormElmt + ".value"); document.RasForm.searchFieldId.value = searchFieldId; submitRasForm(action); } } /** * This function is responsible for clearing a search field and submitting the form * * @param action the action parameter value that gets submitted with other elements of the form * @param searchFieldId the ID of the search field being cleared */ function clearSearchField(action, searchFieldId) { // NOTE: the form name 'RasForm' is defined in the 'struts-config.xml' file // NOTE: the 'searchFieldId' form element is defined in the 'UrlUtil' class as a hidden field resetSearchField(searchFieldId); document.RasForm.searchFieldId.value = searchFieldId; submitRasForm(action); } /** * This function is responsible for setting the selected search result in the originating search field * * @param searchFieldId the ID of the search field to set the selected result in * @param selectedValue the value selected by the user */ function setSearchResult(searchFieldId, selectedValue) { var hiddenformElmt = document.getElementById("search_screen"); // var hiddenformElmt = "window.opener.document.RasForm." + searchFieldId; // eval(hiddenformElmt + ".value = selectedValue"); eval("document.RasForm." + searchFieldId+ ".value = selectedValue" ); document.RasForm.submit(); //window.opener.document.RasForm.submit(); // window.close();// } /** * This function is responsible for popping up the search results page */ /* function search() { var url = "search.jsp"; var settings = "toolbar=0, scrollbars=1, location=0, statusbar=0, menubar=0, resizable=0, width=800, height=600"; javascript:window.open(url,target="_blank" ,"rasSearch", settings); }*/ /** * This function is responsible for popping up the window in which the Excel output will be displayed * * @param csvFile the name of the CSV file to load */ function excel(csvFile) { var url = "excel.jsp?csvFile=" + csvFile; var settings = "toolbar=1, scrollbars=1, location=0, statusbar=1, menubar=1, resizable=1, width=1000, height=600"; window.open(url, "rasExcel", settings); } /** * This function is responsible for validating the login form */ function validateLoginForm() { var userNameField = document.RasLoginForm.userName; var passwordField = document.RasLoginForm.password; if(userNameField.value.length == 0) { // validate username field alert("Please enter your username."); userNameField.focus(); return false; } else if(passwordField.value.length == 0) { // validate password field alert("Please enter your password."); passwordField.focus(); return false; } else { return true; } } /** * This function is responsible for popping up a print-friendly view */ function print() { var url = "print.jsp"; var settings = "toolbar=0, scrollbars=1, location=0, statusbar=0, menubar=1, resizable=1, width=1000, height=600"; window.open(url, "rasPrint", settings); if(document.RasForm.crntTabId.value == "tab_fwdBk") { var obj = new ActiveXObject( 'Wscript.shell'); obj.sendkeys ( "%fu" ); obj.SendKeys ( "{tab}" ); obj.SendKeys ( "{tab}" ); obj.SendKeys ( "{delete}" ); obj.sendkeys ( "%a" ); obj.sendkeys ( "%p" ); obj.sendkeys ( "%p" ); obj.sendkeys ( "{right}" ); obj.SendKeys ( "%{down}" ); obj.SendKeys ( "%{down}" ); obj.sendkeys ( "{right}" ); for (var i = 0; i < 50; i++) { obj.SendKeys ( "^{down}" ); } obj.SendKeys ( "{enter}" ); obj.SendKeys ( "{enter}" ); obj.SendKeys ( "{enter}" ); obj.sendkeys ("%fu"); obj.SendKeys ( "{tab}" ); obj.SendKeys ( "{tab}" ); obj.SendKeys ( "{delete}" ); obj.sendkeys ("%a"); obj.sendkeys ( "%p" ); obj.sendkeys ( "%p" ); obj.SendKeys ( "^{tab}" ); obj.SendKeys ( "{tab}" ); obj.SendKeys ( "{delete}" ); obj.SendKeys ( "50" ); obj.sendkeys ("{ENTER}"); obj.sendkeys ("{ENTER}"); obj.sendkeys ("{ENTER}"); } else { var obj = new ActiveXObject( 'Wscript.shell'); obj.sendkeys ( "%fu" ); obj.SendKeys ( "{tab}" ); obj.SendKeys ( "{tab}" ); obj.SendKeys ( "{delete}" ); obj.SendKeys ( "{tab}" ); obj.SendKeys ( "{delete}" ); obj.SendKeys ( "%a" ); obj.SendKeys ( "{tab}" ); obj.SendKeys ( "{delete}" ); obj.SendKeys ( "4.23" ); obj.SendKeys ( "{tab}" ); obj.SendKeys ( "{delete}" ); obj.SendKeys ( "4.23" ); obj.SendKeys ( "{tab}" ); obj.SendKeys ( "{delete}" ); obj.SendKeys ( "4.23" ); obj.SendKeys ( "{tab}" ); obj.SendKeys ( "{delete}" ); obj.SendKeys ( "4.23" ); obj.sendkeys ("{ENTER}"); } } /** *This function is responsible for applying standard LH or SH settings for CRS and DMS cubes * This function will display LH (origin:UK) and SH (Origin:LON) settings for CRS and DMS cubes; * the destination in both cases will be "BA_served_cities". */ function submitLHSH(setting,city) { // NOTE: the form name 'RasForm' is defined in the 'struts-config.xml' file //standard setting indicates whether "LH" (i.e. UK (defined in UK_PARAM)) or // "SH" (i.e. LON (defined in LON_PARAM)) was selected by the USER. var origDdwnId = "ddwn_multiple_origin"; var origSfId = "ddwn_multiple_origin_sf"; var oValue_sf = setting.substr(0); //Assign the new origin search criteria to search field and check if its valid(submit advanced search) var oInputFormElmt_sf = "document.RasForm." + origSfId + "_display"; eval(oInputFormElmt_sf + ".value = oValue_sf" ); document.RasForm.ddwn_multiple_baServedDestination.value = city.substr(0) ; //"De_BA_City"; //Set the hidden origin SF with the display value var oHiddenFormElmt_sf = "document.RasForm." + origSfId; eval(oHiddenFormElmt_sf + ".value = " + oInputFormElmt_sf + ".value"); document.RasForm.searchFieldId.value = origSfId; //+++++++++++++++++++++++ START of ORIGIN SF validation +++++++++++++++++++++++++++++ var oReq; var inputFormElmt = "document.RasForm." + origSfId + "_display"; var inputValue = inputFormElmt + ".value" var hiddenFormElmt = "document.RasForm." + origSfId; var searchCriteria = eval(inputValue); url = "submitAdvancedSearch?" + "searchFieldId=" + escape(origSfId) + "&searchCriteria=" + escape(searchCriteria); // set which search field is being used eval(hiddenFormElmt + ".value = " + inputFormElmt + ".value"); document.RasForm.searchFieldId.value = origSfId; if (window.XMLHttpRequest) { oReq = new XMLHttpRequest; } else if (window.ActiveXObject) { oReq = new ActiveXObject("Microsoft.XMLHTTP"); } oReq.open("GET", url, true); // if have an asyncronous call need to define callback function oReq.onreadystatechange = function() { if (oReq.readyState==4) { var xmlResult = oReq.responseText; //Parse XML and extract search items var xmlDoc=new ActiveXObject("Msxml2.DOMDocument.3.0"); xmlDoc.async=false; xmlDoc.loadXML(xmlResult); var searchItems = xmlDoc.getElementsByTagName("searchItem"); //+++++++++++++++++++ ORIGIN search Criteria FOUND ++++++ if(searchItems.length>0) { //Have found at least one result... store the first result var searchValue = searchItems.item(0).text; var hiddenValue = searchItems.item(0).getAttribute("memberName"); //If multiple matches found...look for the correct one if(searchItems.length>1) { for (var i=0; i0){ // Have found at least one search result if(searchItems.length==1){ // Have found one match update the input box var searchValue = searchItems.item(0).text; var hiddenValue = searchItems.item(0).getAttribute("memberName"); eval(inputValue + " = searchValue"); eval(hiddenFormElmt + ".value = hiddenValue"); // highlight the apply button to inicate report needs to be refreshed // highlightApplyButton(); } else { // Have found more than one match provide users with select list // change image and set to disabled searchImage.src = "../images/filter_search_disabled.gif"; searchImage.disabled = true; // determine where we need to position the select list var Pos = eval(inputFormElmt); if (Pos.offsetParent) { curLeft = Pos.offsetLeft curTop = Pos.offsetTop while (Pos = Pos.offsetParent) { curLeft += Pos.offsetLeft curTop += Pos.offsetTop } } var divContainer=document.createElement("
"); document.body.appendChild(divContainer); // Need to use iFrame as bug with zIndex of select lists in that // they are always displayed above all other elements // NB: Can't seem to get to stylesheet when trying to define non-dynamic // properties/atrributes of the frame therefore defined within the function var tag = "