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

View File

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