/*--------------------------------------------------------------------- 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. ---------------------------------------------------------------------------------- 08/10/10 (Vidya Ranjit) Currency changes for JAS ---------------------------------------------------------------------------------- 03/05/12 (Vidya Ranjit) Added script to display BI messages ---------------------------------------------------------------------------------- May - 12 (Vidya Ranjit) JB OnD changes ---------------------------------------------------------------------------------- Jun 13 (Vidya Ranjit) 64 bit changes */ 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_timeSeries.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"; } } // alert(document.RasForm.crntTabId.value); if((action == "submit") && (document.RasForm.crntTabId.value == "tab_jbOnD") && ((document.RasForm.reportId.value == "rpt_jbOnD_customerAgent")||(document.RasForm.reportId.value == "rpt_jbOnD_customerAgent2"))) { // alert(document.RasForm.ddwn_jbOnD_timeSeries.value); // alert(document.RasForm.reportId.value); if(document.RasForm.ddwn_jbOnD_timeSeries.value == "Historic_Months") { //display report2...i.e. view of 11 siblings document.RasForm.reportId.value = "rpt_jbOnD_customerAgent2"; } else { //display children of the selected TimeSeries document.RasForm.reportId.value = "rpt_jbOnD_customerAgent"; } } // alert(document.RasForm.crntTabId.value); 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_timeSeries.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"; } } // 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... //not valid for JAS as currency conversion is turned off... /* if(action == "submit" && document.RasForm.crntTabId.value == "tab_fwdBk" && document.RasForm.ddwn_fwdBk_measure.value == "psj" && document.RasForm.ddwn_multiple_currency.value != "GBP") { //alert("Please Note when PSJ is selected, the Currency rate is defaulted to GB Pound."); document.RasForm.ddwn_multiple_currency.value = "GBP"; } //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 != "GBP") { alert("Please Note when Tickets is selected, the Currency rate is defaulted to GB Pound."); document.RasForm.ddwn_multiple_currency.value = "GBP"; } //(VR) Added the condition to check for FWDBK,CB tab also ; also changed the exchange dropdown to a multiple dropdown. //(VR) this condition is no longer required for JAS 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_multiple_currency.value != "GBP") { alert("Please Note when OTX Exchange Rate is selected,the Currency rate is defaulted to GB Pound."); document.RasForm.ddwn_multiple_currency.value = "GBP"; } */ 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); } function include(arr, valueToSearch) { for(var i=0; i