$( function() { $("div.filters div.claimVarianceFilters").dxForm({ colCount: "3", labelLocation: "left", formData: { sd : defaultStartDate, ed: defaultEndDate }, items: [ { dataField : "sd", label : { text: "Start" }, editorType : "dxSelectBox", editorOptions : { dataSource : $("link#startDatesDataURL").attr("href"), xwidth : "200px", valueExpr: "value", displayExpr : "display" } }, { dataField : "ed", label : { text: "End" }, editorType : "dxSelectBox", editorOptions : { dataSource : $("link#endDatesDataURL").attr("href"), xwidth : "200px", valueExpr: "value", displayExpr : "display" } }, { dataField : "excludedOperator", label : { text: "View by Ex. Operator" }, editorType: "dxCheckBox", editorOptions : {} } ], onFieldDataChanged: function(e) { var activeFilterFormDataRaw = e.component.option("formData"); var activeFilterFormData = $.extend( { excludedOperator : false }, activeFilterFormDataRaw ); var sRawURL = $('link#doubleDipAnalyzerDataURL').attr("href"); sURL = Fse.Util.updateURL( sRawURL, { sd : activeFilterFormData.sd, ed : activeFilterFormData.ed, excludedOperator : activeFilterFormData.excludedOperator } ); var oDataGrid = $("#varianceDetailDataGrid").dxDataGrid( "instance" ); oDataGrid.option( "dataSource", new DevExpress.data.DataSource( sURL ) ); if( activeFilterFormData.excludedOperator ) { oDataGrid.columnOption( "beneficiaryoperatorname", { caption: "Excluded Operator" } ); } else { oDataGrid.columnOption( "beneficiaryoperatorname", { caption: "Beneficiary" } ); } sURL = Fse.Util.updateURL( sURL, { grouped : true } ); var oPieChart = $("#varianceSummaryChart").dxPieChart( "instance" ); oPieChart.option( "dataSource", new DevExpress.data.DataSource( sURL ) ); oChartTitle = oPieChart.option( "title" ); if( activeFilterFormData.excludedOperator ) { oChartTitle.subtitle = { text: "by Excluded Operator" }; } else { oChartTitle.subtitle = { text: "by Beneficiary" }; } oPieChart.option( "title", oChartTitle ); sURL = Fse.Util.updateURL( sURL, { object : "doubleDipMonthlySummary" } ); var oChart = $("#monthlyDoubleDipChart").dxChart( "instance" ); oChart.option( "dataSource", sURL ); } }); var dataGrid = $("#varianceDetailDataGrid").dxDataGrid({ dataSource: new DevExpress.data.DataSource(Fse.Util.updateURL( $('link#doubleDipAnalyzerDataURL').attr("href"), { excludedOperator : false } )), paging: { enabled: false }, showBorders: true, grouping: { autoExpandAll: false, expandMode: "rowClick", contextMenuEnabled : true }, export : { enabled: true }, sorting : { mode : "multiple" }, columnChooser : { enabled : true }, groupPanel : { visible: true }, remoteOperations : { grouping : false }, filterRow: { visible: true }, columns: [ { dataField: 'beneficiaryoperatorname', caption: "Beneficiary", visible: true, groupIndex: 0 }, { dataField: 'assignedcontractnbr', caption: "Agreement #", visible : false }, { dataField: 'contractname', caption: "Agreement Name", visible : true }, { dataField: 'claimdate', caption: "Claim Date", visible : true, format : { type : "date" } }, { dataField: 'claiminvoice', caption: "Claim Inv.", visible : true, cellTemplate: function (container, options) { $("", { href: options.data.claimlink } ).append( options.text ).appendTo( container ); } }, { dataField: 'claimref', caption: "Claim Ref.", visible : true }, { dataField: 'claimantpartnername', caption: "Claimant", visible : false }, { dataField: 'claimdollars', caption: "Excluded $", format : { type : "fixedPoint", precision : 2 }, cellTemplate: function (container, options) { $("", { href: options.data.link, target : "_blank" } ).append( options.text ).appendTo( container ); } } ], summary: { groupItems: [{ column: "Excluded $", summaryType: "sum", valueFormat : "currency", alignByColumn: true } ], totalItems: [{ column: "Excluded $", summaryType: "sum", valueFormat : "currency" } ] } }); $("div.claimVarianceView div.filters div.expandAll").dxButton({ icon: "expand", hint: "Expand All", onClick : function(e) { var oDataGrid = $("#varianceDetailDataGrid").dxDataGrid( "instance" ); oDataGrid.expandAll(); } }); $("div.claimVarianceView div.filters div.collapseAll").dxButton({ icon: "collapse", hint: "Collapse All", onClick : function( e ) { var oDataGrid = $("#varianceDetailDataGrid").dxDataGrid( "instance" ); oDataGrid.collapseAll(); } }); $.fn.fsePortlet = function( oOptions ) { var sId = this.attr( "id" ); if( sId ) { oOptions.dashboardId = sId; Fse.Portal.createPortlet( oOptions ); } return this; }; var toggleChartItemVisibility = function(item) { if(item.isVisible()) { item.hide(); } else { item.show(); } }; $("#doubleDipDashboard").fsePortlet( { title : "Double Dip Summary", portletId : "doubleDipSummaryPortlet", contentTemplate : function() { return $("#varianceSummaryChart").dxPieChart( { size : { height: 225 }, dataSource : new DevExpress.data.DataSource(Fse.Util.updateURL( $('link#doubleDipAnalyzerDataURL').attr("href"), { excludedOperator : false, grouped : true } )), series: [ { argumentField: "beneficiaryoperatorname", valueField: "claimdollars", label: { visible: false, connector: { visible: true, width: 1 } }, smallValuesGrouping: { xmode: "smallValueThreshold", mode : "topN", groupName : "All Other", threshold: 500, topCount : 9 } } ], onDone : function( e ) { var ds = e.component.getDataSource(); var items = ds.items(); var nTotal = 0; for( var x = 0; x < items.length; x++ ) { nTotal = nTotal + items[x].claimdollars; } var sFormattedTotal = "$" + DevExpress.localization.formatNumber( nTotal, { type : "fixedPoint", precision : 0 } ); var oTitle = e.component.option( "title" ); oTitle.text = sFormattedTotal + " Savings"; e.component.option( "title", oTitle ); }, tooltip: { enabled: true, format: "currency" , customizeTooltip: function (arg) { return { text: arg.argumentText + "
" + arg.valueText }; } }, legend: { visible : false, orientation: "horizontal", itemTextPosition: "right", horizontalAlignment: "center", verticalAlignment: "bottom", columnCount: 4 }, title : { text: "$0 Savings", subtitle: { text: "by Beneficiary" }}, export : { enabled : false }, xonPointClick: function (e) { var point = e.target; toggleChartItemVisibility(point); }, xonLegendClick: function (e) { var arg = e.target; toggleChartItemVisibility(this.getAllSeries()[0].getPointsByArg(arg)[0]); } }); } }); $("#doubleDipDashboard").fsePortlet( { title : "Double Dip Summary by Month", portletId : "doubleDipMonthlySummaryPortlet", contentTemplate : function() { return $("#monthlyDoubleDipChart").dxChart( { size : { height: 225 }, legend : { visible : false }, title : { text: "Monthly Savings", xsubtitle: { text: "in Dollars" }}, dataSource : Fse.Util.updateURL( $('link#doubleDipAnalyzerDataURL').attr("href"), { object : "doubleDipMonthlySummary" } ), series: { // ... type: 'bar', name : "Dollars", argumentField: 'claimmonth', valueField: 'claimdollars' }, tooltip: { enabled: true, format: "currency" , xcustomizeTooltip: function (arg) { return { text: arg.argumentText + "
" + arg.valueText }; } }, export : { enabled : false } } ); } }); /* var ds = new DevExpress.data.DataSource(Fse.Util.updateURL( $('link#doubleDipAnalyzerDataURL').attr("href"), { excludedOperator : false } )); ds.group( "beneficiaryoperatorname" ); ds.load().done(function(result) { alert( result.length ); }); */ Fse.Portal.suggestFullScreen(); });