123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510 |
- // Licensed Materials - Property of IBM
- //
- // IBM Cognos Products: ps
- //
- // (C) Copyright IBM Corp. 2005, 2014
- //
- // US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- // Copyright (C) 2008 Cognos ULC, an IBM Company. All rights reserved.
- // Cognos (R) is a trademark of Cognos ULC, (formerly Cognos Incorporated).
- /**********************************************************************************************
- Used only on the run with options basic and run with options advanced dialgos
- **********************************************************************************************/
- var g_okCounter = 0;
- // when swtiching from view to background,
- // we have to make sure the correct format is selected
- function switchToBackgroundOptions() {
- var format;
- var frm = document.pform;
-
- if (frm.m_class.value == 'powerPlay8Report' || frm.m_class.value == 'powerPlay8ReportView') {
- format = frm.m_pp8ro_outputFormat.value;
- }
- else {
- format = frm.m_ro_outputFormat.value;
- }
-
- // make sure all the formats are unchecked
- uncheckAllFormats();
-
- // need to deal with the odd formats that have drop downs
- if (format == 'HTML') {
- frm.m_ro_outputF_HTML_Type.checked = true;
- frm.m_ro_outputFormat_HTML.value = 'HTML';
- }
- else if (format == 'singleXLS' || format == 'XLS') {
- frm.m_ro_outputF_XLS2000_Type.checked = true;
- frm.m_ro_outputFormat_XLS2000.value = format;
- }
- // simple checkbox for the other formats
- else {
- if (frm['m_ro_outputFormat_' + format]) {
- frm['m_ro_outputFormat_' + format].checked = true;
- }
- }
-
- // deal with the selection-base interativity controls
- updateInteractivityControls();
-
- var obj_localeDropDown = document.getElementById('outputLocaleDropDown');
- // need to update the locale text
- if (document.getElementById('language_summary_div') && obj_localeDropDown) {
- var localeDisplayName = '';
- // need to get the selected locale from the dropDown
- for (var i = 0; i < obj_localeDropDown.options.length; i++) {
- if (obj_localeDropDown.options[i].selected) {
- localeDisplayName = obj_localeDropDown.options[i].text;
- break;
- }
- }
- document.getElementById('language_summary_div').innerHTML = localeDisplayName;
- }
-
- if (obj_localeDropDown) {
- // make sure there aren't any hidden inputs for the locales since we're about to create one
- removeHiddenLocale();
-
- // create a hidden input for the locale
- createHiddenInput(frm, 'm_ro_outputLocale', obj_localeDropDown.value);
- createHiddenInput(frm, 'language', obj_localeDropDown.value);
- // disable the locale drop down
- obj_localeDropDown.disabled = true;
- }
- // Fix the PDF option summary
- var pdfSummary = '';
- // paper size
- if (document.getElementById('pdf_options_summary')) {
- // page orienation
- if (frm.m_ro_outputPageOrientation && frm.m_ro_outputPageOrientation.value != 'default') {
- for (var i=0; i < frm.m_ro_outputPageOrientation.options.length; i++) {
- if (frm.m_ro_outputPageOrientation.options[i].selected) {
- pdfSummary += frm.m_ro_outputPageOrientation.options[i].text;
- }
- }
- }
- if (frm.m_ro_outputPageDefinition && frm.m_ro_outputPageDefinition.value != 'default') {
- for (var i=0; i < frm.m_ro_outputPageDefinition.options.length; i++) {
- if (frm.m_ro_outputPageDefinition.options[i].selected) {
- if (pdfSummary != '') {
- pdfSummary += ', ';
- }
- pdfSummary += frm.m_ro_outputPageDefinition.options[i].text;
- }
- }
- }
-
- if (frm.m_pdf_userPassword_runOptionPassword_Encrypted && frm.m_pdf_userPassword_runOptionPassword_Encrypted.value != '') {
- if (pdfSummary != '') {
- pdfSummary += ', ';
- }
- pdfSummary += g_validation_msg_array['IDS_PDF_OPEN_PASSWORD_SUMMARY'];
- }
-
- if (frm.m_pdf_ownerPassword_runOptionPassword_Encrypted && frm.m_pdf_ownerPassword_runOptionPassword_Encrypted.value != '') {
- if (pdfSummary != '') {
- pdfSummary += ', ';
- }
- pdfSummary += g_validation_msg_array['IDS_PDF_OPTION_PASSWORD_SUMMARY'];
- }
-
- if (pdfSummary == '') {
- pdfSummary = g_validation_msg_array['IDS_OTHERRUN_NO_PDF_OPTIONS'];
- }
- document.getElementById('pdf_options_summary').innerHTML = pdfSummary;
- }
-
- }
- // when switching from background to view options,
- // we have to remove all but one language and deselect all the format
- function switchToViewOptions() {
- var frm = document.pform;
-
- // keep track of the first checked format so we can set the dropdown menu
- var firstCheckedFormat = uncheckAllFormats();
-
- if (firstCheckedFormat != '' && frm.m_ro_outputFormat) {
- var foundFormat = false;
-
- for (var i=0; i < frm.m_ro_outputFormat.options.length; i++){
- if (frm.m_ro_outputFormat.options[i].value == firstCheckedFormat) {
- foundFormat = true;
- break;
- }
- }
-
- if (foundFormat) {
- frm.m_ro_outputFormat.value = firstCheckedFormat;
- }
- else {
- frm.m_ro_outputFormat.value = frm.m_ro_outputFormat.options[0].value;
- }
- }
- // deal with the selection-base interativity controls
- updateInteractivityControls();
- // make sure we show/hide the correct sub format options
- updateSubOptions();
-
- var firstLocale = removeHiddenLocale();
- var obj_outputLocaleDropDown = document.getElementById('outputLocaleDropDown');
- // Todo: is there a way to sort the locales to get the first one?
- if (obj_outputLocaleDropDown) {
- obj_outputLocaleDropDown.disabled = false;
- obj_outputLocaleDropDown.value = firstLocale;
- }
- }
- // unchecks all the formats and returns the first checked format
- function uncheckAllFormats() {
- var frm = document.pform;
- var firstCheckedFormat = ''
-
- // uncheck all the formats
- for (var i = 0; i < g_formatCheckboxNames.length; i++) {
- var obj_checkbox = frm[g_formatCheckboxNames[i]];
- if (obj_checkbox) {
- // need to get the first format that is checked
- if (obj_checkbox.checked && firstCheckedFormat == '') {
- if (obj_checkbox.name == 'm_ro_outputF_HTML_Type') {
- firstCheckedFormat = 'HTML';
- }
- else if (obj_checkbox.name == 'm_ro_outputF_XLS2000_Type') {
- if (frm.m_ro_outputFormat_XLS2000) {
- firstCheckedFormat = frm.m_ro_outputFormat_XLS2000.value;
- }
- else {
- firstCheckedFormat = 'singleXLS';
- }
- }
- else {
- firstCheckedFormat = obj_checkbox.value;
- }
- }
- obj_checkbox.checked = false;
- }
- }
-
- return firstCheckedFormat;
- }
- // remove any hidden input that have a name of 'inputName' and return its value
- function removeHiddenInputs(inputName) {
- var frm = document.pform;
- var inputValue = '';
-
- // remove all the hidden 'language' fields
- for(var i=0; i < frm.elements.length; i++) {
- var obj = frm.elements[i];
-
- if (obj.name == inputName && obj.type == 'hidden' && obj.parentNode.removeChild ) {
- inputValue = obj.value;
- obj.parentNode.removeChild(obj);
- i--;
- }
- }
- return inputValue;
- }
- // removes all the hidden inputs that have locale information stored
- function removeHiddenLocale() {
- var frm = document.pform;
- var firstLocale = '';
-
- for(var i=0; i < frm.elements.length; i++) {
- var obj = frm.elements[i];
- // loop through all the locale fields
- // if the object is hidden, then it's for a background run
- if (obj.name && obj.name.indexOf('m_ro_outputLocale') == 0 && obj.type == 'hidden') {
- if (firstLocale == '') {
- firstLocale = obj.value;
- }
-
- // set it's value to empty
- obj.value = '';
-
- // remove the hidden input
- if (obj.parentNode.removeChild) {
- obj.parentNode.removeChild(obj);
- i--;
- }
- }
- }
- // remove all the hidden 'language' fields
- removeHiddenInputs('language');
-
- return firstLocale;
- }
- // The enable interactivity checked is duplicated on the advanced run with options
- // dialog. For this reason, we always need to keep one of them (the one that is hidden)
- // disabled at all times.
- function updateInteractivityControls() {
- var frm = document.pform;
-
- // if we're missing any of these controls then just return (happens for a run once)
- if (!frm.runType || !frm.runType[0] || !document.getElementById('background_selectionBasedFeatures') || !document.getElementById('view_selectionBasedFeatures') || !document.getElementById('m_ro_verticalElements') || !document.getElementById('view_verticalElements')) {
- return;
- }
- var runAndView = frm.runType[0].checked;
- var runAndViewCheckbox = document.getElementById('view_selectionBasedFeatures');
- var backgroundRunCheckbox = document.getElementById('background_selectionBasedFeatures');
- var backgroundRunHiddenInput = document.pform.m_ro_selectionBasedFeatures;
- var runAndViewRowsDropDown = document.getElementById('view_verticalElements');
- var backgroundRowsDropDown = document.getElementById('m_ro_verticalElements');
-
- // always keep the checkboxes and hidden inputs in sync
- if (runAndView) {
- runAndViewCheckbox.checked = backgroundRunCheckbox.checked;
- if (backgroundRowsDropDown && runAndViewRowsDropDown)
- {
- for (var i = 0; i < backgroundRowsDropDown.options.length; i++) {
- if (backgroundRowsDropDown.options[i].selected) {
- runAndViewRowsDropDown.options[i].selected = true;
- break;
- }
- }
- }
- }
- else {
- backgroundRunCheckbox.checked = runAndViewCheckbox.checked;
- backgroundRunHiddenInput.value = backgroundRunCheckbox.checked;
- if (runAndViewRowsDropDown && backgroundRowsDropDown)
- {
- for (var i = 0; i < runAndViewRowsDropDown.options.length; i++) {
- if (runAndViewRowsDropDown.options[i].selected) {
- backgroundRowsDropDown.options[i].selected = true;
- break;
- }
- }
- }
-
-
- // if we're doing a run in background, only enable the interactivity checkbox
- // if HTML is selected in the drop down
- updateInteractiveCheckbox();
- updateVerticalElementsSelect();
- }
-
- // make sure only one of them is enabled.
- runAndViewCheckbox.disabled = !runAndView;
- }
- // used to disabled/enable the backgroun run radio-buttons and
- // show the correct run option div
- function updateRunType() {
- var frm = document.pform;
- if (!frm.runType || !frm.backgroundRun) {
- return;
- }
- if (frm.backgroundRun[1]) {
- frm.backgroundRun[0].disabled = frm.runType[0].checked;
- frm.backgroundRun[1].disabled = frm.runType[0].checked;
- }
- if (frm.runType[0].checked) {
- showDynamicDiv('viewReportOptions');
- hideDynamicDiv('backgroundRunOption');
- }
- else {
- showDynamicDiv('backgroundRunOption');
- hideDynamicDiv('viewReportOptions');
- }
- }
- // Used when switching between run and view, and run in the background on the
- // advanced run with options dialog
- function updateOptionType() {
- var frm = document.pform;
- if (!frm.runType || !frm.backgroundRun) {
- return;
- }
- if (frm.runType[0].checked) {
- switchToViewOptions();
- }
- else {
- switchToBackgroundOptions();
- }
- }
- // show or hide the format suboption div
- function updateSubOptions() {
- var format;
- var frm = document.pform;
-
- if (frm.m_class.value == 'powerPlay8Report' || frm.m_class.value == 'powerPlay8ReportView') {
- format = frm.m_pp8ro_outputFormat.value;
- }
- else {
- format = frm.m_ro_outputFormat.value;
- }
- if (format == 'PDF' && document.getElementById('div_pdfOptions')) {
- showDynamicDiv('div_pdfOptions');
- }
- else if (document.getElementById('div_pdfOptions')) {
- hideDynamicDiv('div_pdfOptions');
- }
-
- if (format == 'HTML' && document.getElementById('div_htmlOptions')) {
- showDynamicDiv('div_htmlOptions');
- }
- else if (document.getElementById('div_htmlOptions')){
- hideDynamicDiv('div_htmlOptions');
- }
- }
- // User hit OK on the run with options basic or advanced dialog
- function onClickOK(msg) {
- var frm = document.pform;
-
- g_okCounter++;
- if (g_okCounter > 1) {
- if (g_okCounter > 2) {
- return false;
- }
-
- // If the user doesn't want to see the summary page then warn them the page is already being submitted.
- if (frm.showSummary && frm.showSummary.value == 'n') {
- alert(msg);
- }
- return false;
- }
- return true;
- }
- // user clicken on the advanced options link
- function advancedOptions() {
- // make sure we have the correct delivery input for save, print or email
- createBasicToAdvDeliveryInput();
- document.pform.m.value = 'portal/runWithOptions/report_advanced.xts';
- document.pform.submit();
- }
- // if we're on the basic page, then add the correct hidden inputs to
- // represent the delivery selection
- function createBasicToAdvDeliveryInput() {
- var frm = document.pform;
-
- if (frm.delivery) {
- for(var i=0; i < frm.delivery.length; i++) {
- if (frm.delivery[i].checked) {
- var deliveryValue = frm.delivery[i].value;
-
- if (deliveryValue == 'save') {
- createHiddenInput(frm, 'm_ro_saveOutput', 'true');
- }
- else if (deliveryValue == 'print') {
- createHiddenInput(frm, 'm_ro_print', 'true');
- }
- else if (deliveryValue == 'email') {
- createHiddenInput(frm, 'm_ro_email', 'true');
- }
- else if (deliveryValue == 'mobile') {
- createHiddenInput(frm, 'm_ro_mobile', 'true');
- }
- }
- }
- }
- }
- function runReport() {
- var frm = document.pform;
- if (window.validate && !validate()) {
- return;
- }
-
- // run and view
- if ((frm.delivery && frm.delivery.checked) || (frm.delivery && frm.delivery[0] && frm.delivery[0].checked) || (frm.runType && frm.runType[0] && frm.runType[0].checked)) {
- if (frm.m_class.value == 'powerPlay8Report' || frm.m_class.value == 'powerPlay8ReportView')
- {
- //Only PDF is supported by PowerPlay8 viewer.
- launchPP8Viewer('PDF');
- }
- else {
- launchViewer(frm.m_ro_outputFormat.value);
- }
- }
- // background execution
- else {
- // prepare to run the report in the background
- setupBackgroundRun(frm);
- frm.submit();
- }
- }
- function setupBackgroundRun(frm)
- {
- // if we're on the basic page, then add the correct hidden inputs to
- // represent the delivery selection
- if (frm.delivery) {
- createBasicToAdvDeliveryInput();
- }
- //create a variable to simplify the logic
- var isPowerPlayReport = (frm.m_class.value == 'powerPlay8Report' || frm.m_class.value == 'powerPlay8ReportView');
-
- // if the user doesn't want to prompt or view the summary page then go directly to submit
- if (frm.showSummary && frm.showSummary.value == 'n' && ((!isPowerPlayReport && !frm.m_ro_prompt.checked) || (isPowerPlayReport && !frm.m_pp8ro_prompt.checked))) {
- frm.ps_nav_op.value = 'submit';
- frm.m.value = 'portal/submit.xts';
- }
- else {
- if (isPowerPlayReport) {
- if (frm.m_pp8ro_prompt.checked) {
- frm.method.value = 'edit';
- }
- else {
- frm.method.value = '';
- }
- }
- else {
- if (frm.m_ro_prompt.checked) {
- frm.method.value = 'edit';
- }
- else {
- frm.method.value = '';
- }
- }
- //if we're on the advanced run with options, then disable the outputFormat and outputLocale dropdowns
- if (frm.visited_run_with_options_advanced) {
- if (frm.m_class.value != 'powerPlay8Report' && frm.m_class.value != 'powerPlay8ReportView' && frm.m_ro_outputFormat != null) {
- frm.m_ro_outputFormat.disabled = true;
- }
- if (document.getElementById('outputLocaleDropDown')) {
- document.getElementById('outputLocaleDropDown').disabled = true;
- }
- }
- frm.ps_nav_op.value = 'push';
- frm.m.value = 'portal/runWithOptions/report_confirm.xts';
- }
- }
- // given a form, name and value will create a hidden input
- function createHiddenInput(form, name, value)
- {
- var hiddenElement = document.createElement("input");
- hiddenElement.setAttribute("type","hidden");
- hiddenElement.setAttribute("name",name);
- hiddenElement.setAttribute("value",value);
- form.appendChild(hiddenElement);
- }
|