// Licensed Materials - Property of IBM // // IBM Cognos Products: ps // // (C) Copyright IBM Corp. 2005, 2016 // // 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). /********************************************************************************************** This script is used in many different pages. When making changes insure that you take into account that not all the runOption controls are present on each page. You must check for the presence of controls before manipulating them. **********************************************************************************************/ // g_hasRecipients -- declared in the logicsheet dt:runOptionValidation // g_validation_msg_array -- declared in the logicsheet dt:runOptionValidation var g_formatCheckboxNames = new Array( 'm_ro_outputF_HTML_Type', 'm_ro_outputFormat_PDF', 'm_ro_outputFormat_spreadsheetML', 'm_ro_outputFormat_spreadsheetMLOfficeConnectionEnabled', 'm_ro_outputF_XLS2000_Type', 'm_ro_outputFormat_XLWA', 'm_ro_outputFormat_CSV', 'm_ro_outputFormat_XML', 'm_ro_outputFormat_xlsxData' ); var g_deliveryCheckboxNames = new Array( 'm_ro_archive', 'm_ro_email', 'm_ro_print', 'm_ro_saveOutput', 'm_ro_mobile' ); // HTML dropdown has changed function onChangeHTML() { // make sure the checkbox is checked document.pform.m_ro_outputF_HTML_Type.checked = true; var interactiveChecked = document.getElementById('background_selectionBasedFeatures'); var interactiveVerticalElements = document.getElementById('m_ro_verticalElements'); if (document.pform.m_ro_outputFormat_HTML.value == 'HTML' && interactiveChecked) { interactiveChecked.disabled = false; } else if (interactiveChecked){ interactiveChecked.disabled = true; } if ((document.pform.m_ro_outputFormat_HTML.value == 'HTML' || document.pform.m_ro_outputFormat_HTML.value == 'HTMLFragment' || document.pform.m_ro_outputFormat_HTML.value == 'XHTML') && interactiveVerticalElements) { interactiveVerticalElements.disabled = false; } else if (interactiveVerticalElements){ interactiveVerticalElements.disabled = true; } } function checkSaveOption(saveOptionChecked) { var frm = document.pform; if (frm.m_ro_saveOutput) { frm.m_ro_saveOutput.checked = saveOptionChecked; } // enable/disable the save section if (frm.save_how) { if (frm.save_how[0]) { frm.save_how[0].disabled = !saveOptionChecked; } if (frm.save_how[1]) { frm.save_how[1].disabled = !saveOptionChecked; } } } function selectArchiveCheckbox() { var frm = document.pform; if (frm.m_ro_archive) { frm.m_ro_archive.checked = true; } } // when the printer field changes function onChangePrinter() { var frm = document.pform; if (frm.ro_printer_kw) { frm.ro_printer_kw.value = 'printerAddress'; frm.m_ro_printerAddress.value = frm.select_printerNameAddress.value; frm.select_printerAddress.value = frm.select_printerNameAddress.value; frm.m_ro_printer.value=''; if (frm.printeritem) { frm.printeritem.value = ''; } // make sure the print radio-button or checkbox is selected and a printer has been chosen if (frm.select_printerAddress.value) { selectPrinterButton(); } } } // clears the printer field function clearPrinterField() { var frm = document.pform; if (frm.ro_printer_kw) { frm.ro_printer_kw.value = 'printerAddress'; frm.select_printerAddress.value = ''; frm.m_ro_printerAddress.value = ''; frm.m_ro_printer.value=''; if (frm.printeritem) { frm.printeritem.value = ''; } } } // select the print radio-button or checkbox function selectPrinterButton() { var frm = document.pform; // basic run with options dialog (user doesn't have write) if (frm.delivery && frm.delivery[1].value == 'print') { frm.delivery[1].checked = true; } // basic run with options dialog else if (frm.delivery && frm.delivery[2].value == 'print') { frm.delivery[2].checked = true; } // when we have checkboxes in the deliver section else if (frm.m_ro_print) { frm.m_ro_print.checked = true; } } // enables and selects the save delivery section function enableSave() { var frm = document.pform; if (frm.m_ro_saveOutput) { frm.m_ro_saveOutput.checked = true; } } // OLD function, but it's still getting called by agent studio, so leave the declaration for now function disableDelivery(enabled) { } // validation for all the run options function validateRunOptions() { var frm = document.pform; var formatChecked = false; // for some reports (such as powerPlay8Reports) the user cannot select a format so // there is no need to check the selected formats. var checkBoxesAvailable=false; for (var i=0; i < g_formatCheckboxNames.length; i++) { if (frm[g_formatCheckboxNames[i]]) { checkBoxesAvailable = true; } } // find out if there's a format checked if (checkBoxesAvailable) { for (var i=0; i < g_formatCheckboxNames.length; i++) { if (frm[g_formatCheckboxNames[i]] && frm[g_formatCheckboxNames[i]].checked && !frm[g_formatCheckboxNames[i]].disabled) { formatChecked = true; } } } else { formatChecked = true; } // at least one format must be checked if (!formatChecked) { // Does the user want to select the default format --> if (!window.confirm(g_validation_msg_array['IDS_OTHERRUN_ERR_NO_FORMAT'])) { return false; } // select the default format for the user if ((g_defaultFormat == 'HTML' || g_defaultFormat == 'HTMLFragment' || g_defaultFormat == 'XHTML') && frm.m_ro_outputF_HTML_Type && frm.m_ro_outputFormat_HTML) { frm.m_ro_outputF_HTML_Type.checked = 'true'; frm.m_ro_outputFormat_HTML.value = g_defaultFormat; } if ((g_defaultFormat == 'XLS' || g_defaultFormat == 'singleXLS') && frm.m_ro_outputF_XLS2000_Type && frm.m_ro_outputFormat_XLS2000) { frm.m_ro_outputF_XLS2000_Type.checked = 'true'; frm.m_ro_outputFormat_XLS2000.value = g_defaultFormat; } else if (g_defaultFormat == 'PDF' && frm.m_ro_outputFormat_PDF) { frm.m_ro_outputFormat_PDF.checked = 'true'; } else if(frm['m_ro_outputFormat_' + g_defaultFormat]) { frm['m_ro_outputFormat_' + g_defaultFormat].checked = 'true'; } } // the rest of the behavior are only needed if running in the background if (!frm.background || (frm.background && frm.background[1].checked)) { // if print is selected but no printer is chosen if (frm.m_ro_print && frm.m_ro_print.checked && frm.select_printerAddress.value == '') { alert(g_validation_msg_array['IDS_OTHERRUN_ERR_NO_PRINTER']); return false; } // if save to file system is selected but no archive location is chosen if (frm.m_ro_archive && frm.m_ro_archive.checked && frm.m_arc_archiveLocation.value == '') { alert(g_validation_msg_array['IDS_OTHERRUN_ERR_NO_ARCHIVE_LOCATION']); return false; } // if email is selected without recipients and no bursting if (g_hasRecipients == 'false' && (frm.m_ro_email && frm.m_ro_email.checked) && (!frm.emailToRunOptions || frm.emailToRunOptions.value=='') && (!frm.m_ro_burst || (frm.m_ro_burst && ( (frm.m_ro_burst.type=='checkbox' && !frm.m_ro_burst.checked) || (frm.m_ro_burst.type=='hidden' && frm.m_ro_burst.value!='true'))))) { alert(g_validation_msg_array['IDS_OTHERRUN_ERR_NO_RECIPIENTS']); return false; } // if mobile is selected without recipients and no bursting if (frm.m_ro_mobile && frm.m_ro_mobile.checked && (!frm.mobileDescription || frm.mobileDescription.value==g_validation_msg_array['IDS_OTHERRUN_MOBILE_NO_RECIPIENTS']) && (!frm.m_ro_burst || (frm.m_ro_burst && ( (frm.m_ro_burst.type=='checkbox' && !frm.m_ro_burst.checked) || (frm.m_ro_burst.type=='hidden' && frm.m_ro_burst.value!='true'))))) { alert(g_validation_msg_array['IDS_OTHERRUN_ERR_NO_MOBILE_RECIPIENTS']); return false; } // find out if the user selected a delivery option var deliverySelected = false; for (var i=0; i < g_deliveryCheckboxNames.length; i++){ if (frm[g_deliveryCheckboxNames[i]] && frm[g_deliveryCheckboxNames[i]].checked) { deliverySelected = true; break; } } // if no delivery option is selected if (!deliverySelected) { // does the want to switch to save? if (!window.confirm(g_validation_msg_array['IDS_OTHERRUN_ERR_NO_DELIVERY'])) { return false; } enableSave(); } // bursting and recipients if (frm.emailToRunOptions && frm.emailToRunOptions.value != '' && frm.m_ro_burst && frm.m_ro_burst.checked) { alert(g_validation_msg_array['IDS_OTHERRUN_ERR_BRUST']); } // break down the logic a bit here. When is the URL checkbox checked?. // if the edit email options page has been opened, we can get the value from the form variables, otherwise, get them from the unpacked delivery options var emailAsURL = false; if ((frm.m_ro_emailAsURL && frm.m_ro_emailAsURL.value=='true') || (frm.m_do_emailAsURL && frm.m_do_emailAsURL.value=='true')) { emailAsURL = true; } // do the same for the email as attachment checkbox. var emailAsAttachment = false; if ((frm.m_ro_emailAsAttachment && frm.m_ro_emailAsAttachment.value=='true') || (frm.m_do_emailAsAttachment && frm.m_do_emailAsAttachment.value=='true')) { emailAsAttachment = true; } // email a link without saving if (frm.m_ro_email && frm.m_ro_email.checked && emailAsURL && frm.m_ro_saveOutput && !frm.m_ro_saveOutput.checked) { // does the want to switch to save? // "You must save the reports before including a link to them in the email notification. Click OK to save the reports, or click Cancel to select different options". if (!window.confirm(g_validation_msg_array['IDS_OTHERRUN_ERR_LINK_NO_SAVE'])) { return false; } enableSave(); } // if were sending a notification by email that the reports are complete and save and print aren't selected --> if (frm.m_ro_email.checked && !emailAsURL && !emailAsAttachment && frm.m_ro_saveOutput && (!frm.m_ro_saveOutput || !frm.m_ro_saveOutput.checked) && (!frm.m_ro_archive || !frm.m_ro_archive.checked) && (!frm.m_ro_print || !frm.m_ro_print.checked)) { // "You must save or print the reports before sending an email notification that the reports are complete. Click OK to save the reports, or click Cancel to select different options." if (!window.confirm(g_validation_msg_array['IDS_OTHERRUN_ERR_NOTIFY_NO_SAVE_PRINT'])) { return false; } enableSave(); } } return true; } function updateInteractiveCheckbox() { var frm = document.pform; // make sure the enable selection-based interativity checked is enable/disabled if (document.getElementById('background_selectionBasedFeatures')) { if (frm.m_ro_outputF_HTML_Type && frm.m_ro_outputF_HTML_Type.checked && frm.m_ro_outputFormat_HTML && frm.m_ro_outputFormat_HTML.value == 'HTML') { document.getElementById('background_selectionBasedFeatures').disabled = false; } else { document.getElementById('background_selectionBasedFeatures').disabled = true; } } } function updateVerticalElementsSelect() { var frm = document.pform; if (document.getElementById('m_ro_verticalElements')) { if (frm.m_ro_outputF_HTML_Type && frm.m_ro_outputF_HTML_Type.checked && frm.m_ro_outputFormat_HTML && (frm.m_ro_outputFormat_HTML.value == 'HTML' || frm.m_ro_outputFormat_HTML.value == 'XHTML' || frm.m_ro_outputFormat_HTML.value == 'HTMLFragment')) { document.getElementById('m_ro_verticalElements').disabled = false; } else { document.getElementById('m_ro_verticalElements').disabled = true; } } } function initRunOptions() { var frm = document.pform; updateInteractiveCheckbox(); updateVerticalElementsSelect(); // enable/disable the save section if (frm.m_ro_saveOutput && frm.save_how) { checkSaveOption(frm.m_ro_saveOutput.checked); } } // 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); } function validateRunOptionProperties() { var frm = document.pform; // if any of these controls are missing (read only page?) there's no point in doing any validation if (!frm.m_ro_advancedOutput || !frm.m_ro_selectionBasedFeatures || !frm.m_ro_verticalElements || !frm.m_p_allowNotification) { return true; } var allowNotification = frm.m_p_allowNotification.value == 'true' ? true : false; var advancedSettings = frm.m_ro_advancedOutput.value == 'true' ? true : false; var selectionBasedFeatures = frm.m_ro_selectionBasedFeatures.value == 'true' ? true : false; // Allowing watch rules is dependent on the value of 'Enhanced user features' if (frm.changed_m_ro_advancedOutput.value == '1') { // update allowSubscription to match it frm.m_p_allowSubscription.value = advancedSettings; return true; } //to allow user to remove all existing alerts when changing to disallow alerts (notification) if (frm.original_allowNotification.value == 'true' && !allowNotification) { if (frm.m_canRemoveAll.value == 'true') { if ( window.confirm(g_runOption_allowNotification_msg)) { frm.m_removeAll.value = 'true'; } } } return true; }