diff --git a/lib/constants.dart b/lib/constants.dart index cd409cba8..11795edb3 100644 --- a/lib/constants.dart +++ b/lib/constants.dart @@ -1,3 +1,5 @@ +import 'package:invoiceninja_flutter/data/models/import_model.dart'; + class Constants { //static String get hostedApiUrl => kReleaseMode ? kAppProductionUrl : kAppStagingUrl; static String get hostedApiUrl => kAppProductionUrl; @@ -682,6 +684,32 @@ const String kReportPurchaseOrderItem = 'purchase_order_item'; const String kReportVendor = 'vendor'; const String kReportTransaction = 'transaction'; +final kReportMap = { + kReportClient: ExportType.clients, + kReportClientContact: ExportType.client_contacts, + kReportCredit: ExportType.credits, + kReportCreditItem: null, + kReportDocument: ExportType.documents, + kReportExpense: ExportType.expenses, + kReportInvoice: ExportType.invoices, + kReportPayment: ExportType.payments, + kReportProduct: ExportType.products, + kReportProfitAndLoss: ExportType.profitloss, + kReportTask: ExportType.tasks, + kReportTaskItem: null, + kReportInvoiceTax: ExportType.tax_summary, + kReportPaymentTax: null, + kReportQuote: ExportType.quotes, + kReportInvoiceItem: ExportType.invoice_items, + kReportQuoteItem: ExportType.quote_items, + kReportRecurringExpense: null, + kReportRecurringInvoice: ExportType.recurring_invoices, + kReportPurchaseOrder: null, + kReportPurchaseOrderItem: null, + kReportVendor: null, + kReportTransaction: null, +}; + const String kPdfFieldsClientDetails = 'client_details'; const String kPdfFieldsCompanyDetails = 'company_details'; const String kPdfFieldsCompanyAddress = 'company_address'; diff --git a/lib/ui/reports/reports_screen.dart b/lib/ui/reports/reports_screen.dart index 4640f6447..bdff19f57 100644 --- a/lib/ui/reports/reports_screen.dart +++ b/lib/ui/reports/reports_screen.dart @@ -385,6 +385,13 @@ class ReportsScreen extends StatelessWidget { viewModel.onExportPressed(context); }, ), + AppTextButton( + label: localization.schedule, + isInHeader: true, + onPressed: () { + viewModel.onSchedulePressed(context); + }, + ), ], Padding( padding: const EdgeInsets.only(right: 8), diff --git a/lib/ui/reports/reports_screen_vm.dart b/lib/ui/reports/reports_screen_vm.dart index 58ef63657..33e51873c 100644 --- a/lib/ui/reports/reports_screen_vm.dart +++ b/lib/ui/reports/reports_screen_vm.dart @@ -11,6 +11,9 @@ import 'package:flutter/widgets.dart'; import 'package:built_collection/built_collection.dart'; import 'package:flutter_redux/flutter_redux.dart'; import 'package:flutter_styled_toast/flutter_styled_toast.dart'; +import 'package:invoiceninja_flutter/data/models/import_model.dart'; +import 'package:invoiceninja_flutter/data/models/schedule_model.dart'; +import 'package:invoiceninja_flutter/redux/app/app_actions.dart'; import 'package:invoiceninja_flutter/ui/reports/credit_item_report.dart'; import 'package:invoiceninja_flutter/ui/reports/purchase_order_item_report.dart'; import 'package:invoiceninja_flutter/ui/reports/purchase_order_report.dart'; @@ -81,6 +84,7 @@ class ReportsScreenVM { required this.onReportColumnsChanged, required this.onReportFiltersChanged, required this.onExportPressed, + required this.onSchedulePressed, required this.onReportSorted, required this.groupTotals, required this.reportResult, @@ -94,6 +98,7 @@ class ReportsScreenVM { final GroupTotals groupTotals; final Function(BuildContext, List) onReportColumnsChanged; final Function(BuildContext) onExportPressed; + final Function(BuildContext) onSchedulePressed; final Function(BuildContext, BuiltMap) onReportFiltersChanged; final Function(String?, bool) onReportSorted; @@ -457,6 +462,13 @@ class ReportsScreenVM { )); }); }, + onSchedulePressed: (context) async { + createEntity( + entity: ScheduleEntity(ScheduleEntity.TEMPLATE_EMAIL_REPORT) + .rebuild((b) => b + ..parameters.reportName = + kReportMap[report]?.name ?? ExportType.invoices.name)); + }, onExportPressed: (context) async { final localization = AppLocalization.of(context); final reportState = state.uiState.reportsUIState; diff --git a/lib/ui/schedule/schedule_list_item.dart b/lib/ui/schedule/schedule_list_item.dart index 965213275..366defe34 100644 --- a/lib/ui/schedule/schedule_list_item.dart +++ b/lib/ui/schedule/schedule_list_item.dart @@ -75,6 +75,8 @@ class ScheduleListItem extends StatelessWidget { } subtitle += ' • ' + localization.lookup(kFrequencies[schedule.frequencyId]); + } else if (schedule.template == ScheduleEntity.TEMPLATE_EMAIL_REPORT) { + title += ': ' + localization.lookup(schedule.parameters.reportName); } return DismissibleEntity(