Minor fixes for invoice export

This commit is contained in:
Hillel Coren 2016-05-22 20:01:37 +03:00
parent ac09d86f68
commit 371f224c24
2 changed files with 15 additions and 12 deletions

View File

@ -84,13 +84,14 @@ class ExportController extends BaseController
if ($key === 'account' || $key === 'title' || $key === 'multiUser') {
continue;
}
if ($key === 'recurringInvoices') {
$key = 'recurring_invoices';
}
$label = trans("texts.{$key}");
$excel->sheet($label, function($sheet) use ($key, $data) {
if ($key === 'quotes') {
$key = 'invoices';
$data['entityType'] = ENTITY_QUOTE;
} elseif ($key === 'recurringInvoices') {
$key = 'recurring_invoices';
}
$sheet->loadView("export.{$key}", $data);
});
@ -107,7 +108,7 @@ class ExportController extends BaseController
'title' => 'Invoice Ninja v' . NINJA_VERSION . ' - ' . $account->formatDateTime($account->getDateTime()),
'multiUser' => $account->users->count() > 1
];
if ($request->input(ENTITY_CLIENT)) {
$data['clients'] = Client::scope()
->with('user', 'contacts', 'country')
@ -123,14 +124,14 @@ class ExportController extends BaseController
->with('user', 'client.contacts')
->get();
}
if ($request->input(ENTITY_TASK)) {
$data['tasks'] = Task::scope()
->with('user', 'client.contacts')
->withArchived()
->get();
}
if ($request->input(ENTITY_INVOICE)) {
$data['invoices'] = Invoice::scope()
->with('user', 'client.contacts', 'invoice_status')
@ -138,7 +139,7 @@ class ExportController extends BaseController
->where('is_quote', '=', false)
->where('is_recurring', '=', false)
->get();
$data['quotes'] = Invoice::scope()
->with('user', 'client.contacts', 'invoice_status')
->withArchived()
@ -153,7 +154,7 @@ class ExportController extends BaseController
->where('is_recurring', '=', true)
->get();
}
if ($request->input(ENTITY_PAYMENT)) {
$data['payments'] = Payment::scope()
->withArchived()
@ -161,7 +162,7 @@ class ExportController extends BaseController
->get();
}
if ($request->input(ENTITY_VENDOR)) {
$data['clients'] = Vendor::scope()
->with('user', 'vendor_contacts', 'country')
@ -172,14 +173,14 @@ class ExportController extends BaseController
->with('user', 'vendor.vendor_contacts')
->withTrashed()
->get();
/*
$data['expenses'] = Credit::scope()
->with('user', 'client.contacts')
->get();
*/
}
return $data;
}
}
}

View File

@ -45,6 +45,8 @@ class InvoicePresenter extends Presenter {
return trans('texts.deleted');
} elseif ($this->entity->trashed()) {
return trans('texts.archived');
} elseif ($this->entity->is_recurring) {
return trans('texts.active');
} else {
$status = $this->entity->invoice_status ? $this->entity->invoice_status->name : 'draft';
$status = strtolower($status);
@ -82,4 +84,4 @@ class InvoicePresenter extends Presenter {
$client = $this->entity->client;
return count($client->contacts) ? $client->contacts[0]->email : '';
}
}
}