diff --git a/app/Http/Controllers/ExportController.php b/app/Http/Controllers/ExportController.php index f1e74bd2a924..ed0d1480e12e 100644 --- a/app/Http/Controllers/ExportController.php +++ b/app/Http/Controllers/ExportController.php @@ -32,7 +32,21 @@ class ExportController extends BaseController { $format = $request->input('format'); $date = date('Y-m-d'); - $fileName = "invoice-ninja-{$date}"; + + // set the filename based on the entity types selected + if ($request->include == 'all') { + $fileName = "invoice-ninja-{$date}"; + } else { + $fields = $request->all(); + $fields = array_filter(array_map(function ($key) { + if ( ! in_array($key, ['format', 'include', '_token'])) { + return $key; + } else { + return null; + } + }, array_keys($fields), $fields)); + $fileName = "invoice-ninja-" . join('-', $fields) . "-{$date}"; + } if ($format === 'JSON') { return $this->returnJSON($request, $fileName); diff --git a/app/Models/Invoice.php b/app/Models/Invoice.php index 1e125117b769..16929178c816 100644 --- a/app/Models/Invoice.php +++ b/app/Models/Invoice.php @@ -77,6 +77,10 @@ class Invoice extends EntityModel implements BalanceAffecting * @var string */ public static $fieldInvoiceNumber = 'invoice_number'; + /** + * @var string + */ + public static $fieldPONumber = 'po_number'; /** * @var string */ @@ -110,6 +114,7 @@ class Invoice extends EntityModel implements BalanceAffecting return [ Client::$fieldName, Invoice::$fieldInvoiceNumber, + Invoice::$fieldPONumber, Invoice::$fieldInvoiceDate, Invoice::$fieldDueDate, Invoice::$fieldAmount, @@ -127,9 +132,11 @@ class Invoice extends EntityModel implements BalanceAffecting return [ 'number^po' => 'invoice_number', 'amount' => 'amount', - 'organization' => 'name', + 'client|organization' => 'name', 'paid^date' => 'paid', - 'invoice_date|create_date' => 'invoice_date', + 'invoice date|create date' => 'invoice_date', + 'po number' => 'po_number', + 'due date' => 'due_date', 'terms' => 'terms', 'notes' => 'notes', ]; diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index ed7013b2b25a..f49705cfb42a 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -2317,6 +2317,7 @@ $LANG = array( 'domain_help' => 'Used in the client portal and when sending emails.', 'domain_help_website' => 'Used when sending emails.', 'preview' => 'Preview', + 'import_invoices' => 'Import Invoices', ); diff --git a/resources/views/export/invoices.blade.php b/resources/views/export/invoices.blade.php index 6aa9fd65169e..9f5dc26b21a6 100644 --- a/resources/views/export/invoices.blade.php +++ b/resources/views/export/invoices.blade.php @@ -5,8 +5,8 @@