RunReportsWidget = function() { let instance = this; instance.contentElement = $("
").css( { "padding" : "10px" } ); instance.container = null; let contentElement = instance.contentElement; contentElement.dxDataGrid( { xwidth : 400, height : 400, showColumnHeaders : true, showColumnLines : false, rowAlternationEnabled : true, showBorders : true, scrolling : { mode : "virtual" }, dataSource : Fse.Data.newDataSource( { object : "RPT.mySavedReports", paginate : false, keyField : "quickReportURL" } ), columns : [ { dataField : "userReportGroup", groupIndex : 0, caption : "Group" }, { dataField : "userReportName", caption : "Saved Report" } ], onCellClick : function( e ) { if( e.rowType != "data" ) { return; } if( instance.container && instance.container.hide ) { instance.container.hide(); } Fse.RPT.runQuickReport( e.data.quickReportURL ); $("#report-center-view-options-switch").removeClass( "finished" ).addClass( "running" ); } }) } RunReportsWidget.prototype.constructor = RunReportsWidget; RunReportsWidget.prototype.element = function() { return this.contentElement; } RunReportsWidget.prototype.setContainer = function( container ) { this.container = container; } ViewReportsWidget = function() { let instance = this; instance.container = null; instance.contentElement = $("
"); let contentElement = instance.contentElement; let manageReports = function( newVersion ) { if( instance.container && instance.container.hide ) { instance.container.hide(); } if( newVersion ) { let mrw = new ManageReportsWidget(); mrw.show(); } else { Fse.RPT.showReportResultsDialog('manageReportPortletDialog$'); } } let clearAll = function() { if( ! confirm( "Clear completed report requests?" ) ) { return; } if( instance.container && instance.container.hide ) { instance.container.hide(); let clearUserReportRequestsURL = Fse.Util.updateURL2( $("link#rptHandlerLink").attr( "href" ), { "mode" : "direct", "do" : "clearUserREportRequests" } ) $.ajax( { url : clearUserReportRequestsURL, method : "post", data : { userId : Fse.Portal.appConfiguration.STP.userId } }) } } let buttons = $("
").css( { "padding-left" : "10px", "padding-right" : "10px" } ).dxToolbar( { items : [ { location : "after", widget : "dxButton", options : { text : "Clear All", onClick : function() { clearAll(); } } }, { location : "after", widget : "dxButton", options : { text : "Manage", onClick : function() { manageReports( true ); } } }, // { // location : "after", // widget : "dxButton", // options : { // text : "Old", // onClick : function() { // manageReports(); // } // } // }, { location : "after", widget : "dxButton", options : { icon : "refresh", onClick : function() { instance.loadUserReportRequests(); } } } ] }).appendTo( contentElement ); let list = $("
").css( "padding", "10px" ).dxDataGrid( { height : 300, // dataSource : Fse.Data.newDataSource( { paginate : false, object : "RPT.userReportRequests", keyField : "reportRequestId" }), showColumnHeaders : true, showColumnLines : false, rowAlternationEnabled : true, showBorders : true, scrolling : { mode : "virtual" }, columns : [ { caption : "Report", cellTemplate : function( container, options ) { let data = options.data; let reportDisplay = $("
").text( data.reportLabel ? data.reportLabel : data.reportName ); let statusDisplay = $("
").text( data.statusDisplay ).css( { "font-size" : "smaller" } ); let cell = $("
") .append( reportDisplay ) .append( statusDisplay ); container.append( cell ); } }, { caption : "Status", alignment : "center", width : 70, cellTemplate : function( container, options) { let data = options.data; let cell = $("
"); if( data.status === "COMPLETE" ) { let icon = null; switch ( data.fileType ) { case "PDF": icon = "pdffile" break; case "XLSX" : case "XLS" : case "XLSM" : case "XLSB" : icon = "xlsfile" break; case "TXT" : icon = "textdocument"; break; } let iconTitle = "Download"; if( data.emailId ) { icon = "email"; iconTitle = "View Email"; } if( ! icon ) { icon = "file"; } let iconElement = $("") .attr( "title", iconTitle ) .addClass( `dx-icon dx-icon-${icon}`) .css( { "font-size" : "22px", "cursor" : "pointer" } ) .on( "click", function() { instance.viewReport( data ); } ); cell.append( iconElement ); } else if ( data.status == "PENDING" ) { let iconElement = $("") .attr( "title", "Cancel" ) .addClass( `dx-icon dx-icon-clear`) .css( { "font-size" : "22px", "cursor" : "pointer" } ) .on( "click", function() { instance.cancelReport( data ); } ); cell.append( iconElement ); } else { cell.append( "na" ); } container.append( cell ); } } ] }).appendTo( contentElement ); instance.userReportRequestsDataGrid = list.dxDataGrid( "instance" ); instance.loadUserReportRequests(); } ViewReportsWidget.prototype.constructor = ViewReportsWidget; ViewReportsWidget.prototype.element = function() { return this.contentElement; } ViewReportsWidget.prototype.setContainer = function( container ) { this.container = container; } ViewReportsWidget.prototype.viewReport = function( userReportRequest ) { if( userReportRequest.status !== "COMPLETE" ) { return; } if( userReportRequest.reportMethod === "DOWNLOAD" ) { window.location.href = userReportRequest.downloadURL; } else if( userReportRequest.reportMethod === "EMAIL" ) { Fse.Portal.popupWindow('Email',userReportRequest.emailURL,750); } if( this.container ) { this.container.hide(); } } ViewReportsWidget.prototype.cancelReport = function( userReportRequest ) { let instance = this; if( userReportRequest.status != "PENDING" ) { return; } if( ! confirm( `Cancel ${userReportRequest.reportLabel}?` )) { return; } let cancelReportURL = Fse.Util.updateURL2( $("link#rptHandlerLink").attr( "href" ), { "mode" : "direct", "do" : "cancelReport" } ); $.ajax({ method : "post", url : cancelReportURL, data : { reportRequestId : userReportRequest.reportRequestId } }).then( function() { instance.loadUserReportRequests(); }) } ViewReportsWidget.prototype.loadUserReportRequests = function() { let instance = this; let store = Fse.Data.newDataSource( { paginate : false, object : "RPT.userReportRequests", keyField : "reportRequestId" }).store(); store.load().done( function( data ) { let dataSourceConfig = { store : { type : "array", data : data, key : "reportRequestId" } }; instance.userReportRequestsDataGrid.option( "dataSource", dataSourceConfig ); }).fail( function( x ) { console.log( x ); }) } ManageReportsWidget = function() { } ManageReportsWidget.prototype.constructor = ManageReportsWidget; ManageReportsWidget.prototype.show = function() { let popup = $("
").dxPopup( { title : "Manage Report Results", height : "auto", width : 600, contentTemplate: function() { let dataGrid = $("
").dxDataGrid( { showBorders : true, dataSource : Fse.Data.newDataSource( { object : "RPT.userReportRequests", key : "reportRequestId" } ), filterRow : { visible : true, }, rowAlternationEnabled : true, onCellDblClick : function( e ) { if( e.column.dataField != "reportName" ) return; if( ! e.data.reportRequestId ) return; if( Fse.Portal.appConfiguration.STP.isProduction != "N" ) return; let runURL = Fse.Util.updateURL( "https://dev.fsenablers.com/fse/z_cfmodMaster/RPT/tools/reportGenerationOutput.cfm", { rr : e.data.reportRequestId } ); window.open( runURL ); }, columns : [ { dataField : "reportName", caption : "Report", allowFiltering : true, cellTemplate : function( container, options ) { if( options.data.referenceName ) { container.append( $( "
" ).text( options.data.referenceName ) ); } else { container.append( $("
").text( options.data.reportName ) ); } container.append( $("
").text( options.data.statusDisplay ).css( { "font-size" : "10px", "color" : options.data.status == "ERROR" ? "red" : "silver" }) ); } }, { dataField : "status", width : 50, alignment : "center", allowFiltering : false, cellTemplate : function( container, options ) { if( options.data.status != "COMPLETE" ) { container.append( $("").text( "na" ) ) } else { if( options.data.reportMethod == "DOWNLOAD" ) { let iconClass = "dx-icon-doc"; if( options.data.fileType == "PDF" ) { iconClass = "dx-icon-pdffile"; } if( options.data.fileType == "XLSX" ) { iconClass = "dx-icon-xlsxfile"; } if( options.data.fileType == "XLS" ) { iconClass = "dx-icon-xlsfile"; } if( options.data.fileType == "TXT" ) { iconClass = "dx-icon-textdocument"; } $("").addClass( iconClass ).css( { "cursor" : "pointer" } ).on( "click", function( jqe ) { window.location.href = options.data.downloadURL; }).appendTo( container ); } else if( options.data.reportMethod == "EMAIL" && options.data.emailURL ) { $("").addClass( "dx-icon-email" ).css( { "cursor" : "pointer" } ).on( "click", function( jqe ) { Fse.Portal.popupWindow('Email',options.data.emailURL,750); }).appendTo( container ); } } } } , { type : "buttons", width : 35, allowSearch : false, buttons : [ { template : function( container, options ) { let menuItems = []; if( options.data.status == "COMPLETE" || options.data.downloadURL ) { menuItems.push( { text : "Email", onClick : function( e ) { let es = new EmailSender( { trackingCode : "RPT700", subject : options.data.referenceName ? options.data.referenceName : options.data.reportName, attachmentLinks : [ { text : options.data.fileName, href : options.data.downloadURL + `&fileName=${encodeURIComponent( options.data.fileName )}` } ] }) es.show(); } }) } if( options.data.status == "COMPLETE" || options.data.status == "ERROR" || options.data.status == "CANCELLED" ) { menuItems.push ( { text : "Remove", onClick : function( e ) { if( confirm( "Clear completed report request?" )) { let removeReportData = { reportRequestId : options.data.reportRequestId, userId : parseInt( Fse.Portal.appConfiguration.STP.userId ) } $.ajax( { method : "POST", url : Fse.Util.updateURL( $("link#PortalDocRootURL").attr( "href") + "/apps/RPT/index.cfm", { do : "clearUserReportRequest", mode : "direct" } ), data : removeReportData }).done( function() { dataGrid.refresh(); }) } } }) } if( ! menuItems.length ) return; const b = $("
").addClass("dx-icon-overflow").css("display", "inline-block"); b.on( "click", function( jqe ) { $("
").dxContextMenu( { items : menuItems, target : b, hideOnOutsideClick : true, onHidden : function( e ) { e.component.element().remove(); } }).appendTo( $("body") ).dxContextMenu( "show" ); }) return b; } } ] } ], scrolling : { mode : "virtual" }, height : 300 }).dxDataGrid( "instance" ); return dataGrid.element(); }, toolbarItems : [ { toolbar : "bottom", location : "after", widget : "dxButton", options : { text : "Close", onClick : function( e ) { popup.hide(); } } } ], onHidden : function( e ) { e.component.element().remove(); } }).dxPopup( "instance" ); $("body").append( popup.element() ); popup.show(); } showClientPermissionList = function() { $("
").dxPopup( { title : "User's Granted Permissions", height : 610, width : 860, contentTemplate : function() { return $("
").dxDataGrid( { dataSource : Fse.Data.newDataSource( { object : "SYS.clientPermissionList", keyField : "permission" } ), width : "100%", height : "100%", scrolling : { mode : "virtual" }, showBorders : true, filterRow : { visible : true }, columns : [ { dataField : "permission", caption : "Permission" }, { dataField : "name", width : 250, caption : "Permission Name" }, { dataField : "description" } ] }); }, hideOnOutsideClick : true, onHidden : function( e ) { e.component.element().remove(); e.component.dispose(); } }) .appendTo( $("body") ) .dxPopup( "instance" ).show(); } let showPasswordChangePopup = function() { let form = null; let notificationSocket = $("
").css( { color : "#F53611", "padding-top" : "15px" }) let popup = $("
").dxPopup( { title : "Change Password", hideOnOutsideClick : true, width : 400, height : "auto", contentTemplate : function() { form = $("
").dxForm( { items : [ { dataField : "currentPassword", caption : "Current Password", isRequired : true, editorOptions : { mode : "password" } }, { dataField : "newPassword", caption : "New Password", isRequired : true, editorOptions : { mode : "password" }, validationRules : [ { type: "stringLength", message: "Passwords must be at least 8 characaters", min : 8 }, { type : "pattern", pattern : "^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d).*$", message : "Passwords must contain at least 1 uppercase letter, 1 lowercase letter and 1 numeric character" } ] }, { dataField : "confirmPassword", caption : "Confirm New", isRequired : true, editorOptions : { mode : "password" } } ] }).dxForm( "instance" ) let content = $("
") .append( $("

").css( { "font-size" : "larger" } ).text( "Enter your current password, a new password and confirmation. Upon successful password change you will be required to login again with the new password." )) .append( form.element() ) .append( $("

").dxToolbar( { items : [ { location : "before", template : function() { return notificationSocket } } ], height : 30 }) ); return content; }, toolbarItems : [ { toolbar : "bottom", location : "after", widget : "dxButton", options : { type : "default", text : "Change Password", onClick : function( e ) { let vr = form.validate(); if( ! vr.isValid ) return; let data = form.option( "formData" ); if( data.newPassword !== data.confirmPassword ) { notificationSocket.text( "New Password and Confirm Password do not match" ); // DevExpress.ui.notify( { message: "New Password and Confirm Password do not match", width : 600, shading: true, position : "center" }, "error", 750 ); return; } let portalDocRootURL = $("link#PortalDocRootURL").attr( "href" ); $.ajax( { method : "POST", url : `${portalDocRootURL}/public/actions/changePassword.cfm`, data : data }).done( function( passwordChange ) { if( passwordChange.message ) { notificationSocket.text( passwordChange.message ); } else { notificationSocket.text( '' ); } if( passwordChange.passwordChanged ) { notificationSocket.css( { color : "#2B8000" } ) } else { notificationSocket.css( { color : "#F53611" } ) } if( passwordChange.passwordChanged ) { popup.hide(); } if( passwordChange.logoff ) { alert( passwordChange.message ); let logoffURL = `${portalDocRootURL}/public/actions/logoff.cfm`; window.location.href = logoffURL; } }) } } } ], onHidden : function( e ) { e.component.element().remove(); e.component.dispose(); } }).dxPopup("instance"); $("body").append( popup.element() ) popup.show(); } UserProfileEditor = function() { let instance = this; instance.container = null; instance.contentElement = $("
").css( { "padding" : "10px" } ); let contentElement = instance.contentElement; let portalDocRootURL = $("link#PortalDocRootURL").attr( "href" ); let userData = Fse.Portal.appConfiguration.STP; let hide = function() { if( instance.container && instance.container.hide ) { instance.container.hide(); } } let profileForm = $("
").attr( { "method" : "POST", "action" : `${portalDocRootURL}/apps/ADM/index.cfm?do=updateUserProfile`, "name" : "frm_accountProfile_2" }) let profileReadOnly = userData.clientStpAdminUser == "Y" ? true : false; let submitButton = null; let profileFormObject = $("
").dxForm( { validationGroup : "userProfile", formData : { userFirstName : userData.userFirstName, userLastName : userData.userLastName, userAddress1 : userData.userAddress1, userAddress2 : userData.userAddress2, userCity : userData.userCity, userState : userData.userState, userZipCode : userData.userZipCode, userTitle : userData.userTitle, userPhone : userData.userPhone, userCell : userData.userCell }, items : [ { name : "userFirstName", dataField : "userFirstName", isRequired : true, label : { location : "left", text : "First Name" }, editorOptions : { maxLength : 50, readOnly : profileReadOnly }}, { name : "userLastName", dataField : "userLastName", isRequired : true, label : { location : "left", text : "Last Name" }, editorOptions : { maxLength : 50, readOnly : profileReadOnly }}, { dataField : "userAddress1", isRequired : false, label : { location : "left", text : "Address" }, editorOptions : { maxLength : 75, readOnly : profileReadOnly }}, { dataField : "userAddress2", isRequired : false, label : { template : function() { return $("
") } }, editorOptions : { maxLength : 75, readOnly : profileReadOnly }}, { dataField : "userCity", isRequired : false, label : { location : "left", text : "City" }, editorOptions : { maxLength : 25, readOnly : profileReadOnly }}, { dataField : "userState", isRequired : false, label : { location : "left", text : "State" }, editorOptions : { maxLength : 25, readOnly : profileReadOnly }}, { dataField : "userZipCode", isRequired : false, label : { location : "left", text : "Zip Code" }, editorOptions : { maxLength : 10, readOnly : profileReadOnly }}, { dataField : "userTitle", isRequired : false, label : { location : "left", text : "Title" }, editorOptions : { maxLength : 50, readOnly : profileReadOnly }}, { dataField : "userPhone", isRequired : false, label : { location : "left", text : "Phone" }, editorOptions : { maxLength : 30, readOnly : profileReadOnly }}, { dataField : "userCell", isRequired : false, label : { location : "left", text : "Cell" }, editorOptions : { maxLength : 30, readOnly : profileReadOnly }} ], onFieldDataChanged : function( e ) { submitButton.option( { disabled : false } ); } }).appendTo( profileForm ).dxForm( "instance" ); $("