1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-08 12:12:48 +01:00

Improvements to CSV import/export

This commit is contained in:
Hillel Coren 2017-01-15 20:38:36 +02:00
parent 923bea823e
commit c8419c14d1
4 changed files with 28 additions and 6 deletions

View File

@ -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);

View File

@ -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',
];

View File

@ -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',
);

View File

@ -5,8 +5,8 @@
<td>{{ trans('texts.user') }}</td>
@endif
<td>{{ trans(isset($entityType) && $entityType == ENTITY_QUOTE ? 'texts.quote_number' : 'texts.invoice_number') }}</td>
<td>{{ trans('texts.balance') }}</td>
<td>{{ trans('texts.amount') }}</td>
<td>{{ trans('texts.paid') }}</td>
<td>{{ trans('texts.po_number') }}</td>
<td>{{ trans('texts.status') }}</td>
<td>{{ trans(isset($entityType) && $entityType == ENTITY_QUOTE ? 'texts.quote_date' : 'texts.invoice_date') }}</td>
@ -34,8 +34,8 @@
<td>{{ $invoice->present()->user }}</td>
@endif
<td>{{ $invoice->invoice_number }}</td>
<td>{{ $account->formatMoney($invoice->balance, $invoice->client) }}</td>
<td>{{ $account->formatMoney($invoice->amount, $invoice->client) }}</td>
<td>{{ $account->formatMoney($invoice->amount - $invoice->balance, $invoice->client) }}</td>
<td>{{ $invoice->po_number }}</td>
<td>{{ $invoice->present()->status }}</td>
<td>{{ $invoice->present()->invoice_date }}</td>
@ -56,4 +56,4 @@
@endif
@endforeach
<tr><td></td></tr>
<tr><td></td></tr>