load( local!productGroups: rule!ICAMS_getProductGroups(), local!pagingInfo: a!pagingInfo( startIndex: 1, batchSize: 20, sort: a!sortInfo( field: "ageDays", ascending: false ) ), local!filterModuleAge: - 1, local!filterPurchaseGtTarget: - 1, local!filterAuditGtTarget: - 1, local!filterDemandType: "Both", local!filterProductGroup, with( local!logicalExpressionSearchFilter: rule!ICAMS_createLogicalExpressionForInventoryAging( filterProductGroup: local!filterProductGroup, filterModuleAge: local!filterModuleAge, filterPurchaseGtTarget: local!filterPurchaseGtTarget, filterAuditGtTarget: local!filterAuditGtTarget, filterDemandType: local!filterDemandType ), local!datasubset: rule!ICAMS_getModulesForInventoryAgingReport( logicalExpression: local!logicalExpressionSearchFilter, pagingInfo: local!pagingInfo ), local!exportLink: rule!ICAMS_createLinkToDownloadInventoryAgingReportData( productGroupFilter: local!filterProductGroup, moduleAgeFilter: local!filterModuleAge, purchaseGtTargetFilter: local!filterPurchaseGtTarget, auditGtTargetFilter: local!filterAuditGtTarget, demandTypeFilter: local!filterDemandType ), a!dashboardLayout( firstColumnContents: { a!sectionLayout( label: "Inventory Aging Report", firstColumnContents: { a!radioButtonField( label: "Module Age Greater Than", placeholderLabel: "Filter by Module Age ...", choiceLabels: { "1 Year", "3 Years", "No Filter" }, choiceValues: { 1, 3, - 1 }, value: local!filterModuleAge, saveInto: local!filterModuleAge, choiceLayout: "COMPACT" ), a!dropdownField( label: "Product Group", placeholderLabel: "-- select --", choiceLabels: local!productGroups, choiceValues: local!productGroups, value: local!filterProductGroup, saveInto: local!filterProductGroup ), a!radioButtonField( label: "Demand type", choiceLabels: { "Tactical", "Strategic", "Both" }, choiceValues: { "Tactical", "Strategic", "Both" }, saveInto: local!filterDemandType, value: local!filterDemandType, choiceLayout: "COMPACT" ) }, secondColumnContents: { a!radioButtonField( label: "Value > 110% of Target", choiceLabels: { "Yes", "No", "No Filter" }, choiceValues: { 1, 0, - 1 }, saveInto: local!filterPurchaseGtTarget, value: local!filterPurchaseGtTarget, choiceLayout: "COMPACT" ), a!radioButtonField( label: "Audit Deduction > 25% of Target", choiceLabels: { "Yes", "No", "No Filter" }, choiceValues: { 1, 0, - 1 }, saveInto: local!filterAuditGtTarget, value: local!filterAuditGtTarget, choiceLayout: "COMPACT" ), } ), a!gridField( emptyGridMessage: "No Modules Found", totalCount: local!datasubset.totalCount, columns: { a!gridTextColumn( label: "New Part Number", field: "newPartNumber", data: index( local!datasubset.data, "newPartNumber", null ) ), a!gridTextColumn( label: "Serial Number", field: "serialNumber", data: index( local!datasubset.data, "serialNumber", null ) ), a!gridTextColumn( label: "STD Description", field: "stdDescription", data: index( local!datasubset.data, "stdDescription", null ) ), a!gridTextColumn( label: "Product Group", field: "productGroup", data: index( local!datasubset.data, "productGroup", null ) ), a!gridTextColumn( label: "CA Number", field: "coreAcquisitionNumber", data: index( local!datasubset.data, "coreAcquisitionNumber", null ) ), a!gridTextColumn( label: "Receipt Date", field: "receiptDate", data: index( local!datasubset.data, "receiptDate", null ) ), a!gridTextColumn( label: "Age (Days)", field: "ageDays", data: index( local!datasubset.data, "ageDays", null ) ), a!gridTextColumn( label: "Net Value", field: "netPrice", data: index( local!datasubset.data, "netPrice", null ) ), a!gridTextColumn( label: "Reserves", field: "reserves", data: index( local!datasubset.data, "reserves", null ) ), a!gridTextColumn( label: "Demand Type", field: "demandType", data: index( local!datasubset.data, "demandType", null ) ) }, value: local!pagingInfo, /*saveInto: {a!save(local!pagingInfo, topaginginfo(1,20)) }*/ saveInto: local!pagingInfo ), if( rule!APN_isBlank( local!exportLink ), {}, a!linkField( links: a!safeLink( label: "Click here to export this data to Excel.", uri: local!exportLink ) ) ), if( or( rule!APN_isBlank( filterModuleAge ), local!filterModuleAge =- 1 ), {}, { a!sectionLayout( firstColumnContents: {}, secondColumnContents: { a!gridField( totalCount: 1, columns: { a!gridTextColumn( label: "Total Net Value", field: "netValue", data: sum( index( local!datasubset.data, "netPrice", 0 ) ) ), a!gridTextColumn( label: "Total Reserves", field: "reserves", data: sum( index( local!datasubset.data, "reserves", 0 ) ) ) }, value: a!pagingInfo( 1, - 1 ) ) } ) } ) } ) ) )