Improvements to data export

This commit is contained in:
Hillel Coren 2016-02-25 11:25:07 +02:00
parent fb959c1487
commit 01f9634237
6 changed files with 46 additions and 16 deletions

View File

@ -109,8 +109,7 @@ class ExportController extends BaseController
if ($request->input(ENTITY_CLIENT)) {
$data['clients'] = Client::scope()
->with('user', 'contacts', 'country')
->withTrashed()
->where('is_deleted', '=', false)
->withArchived()
->get();
$data['contacts'] = Contact::scope()
@ -126,33 +125,36 @@ class ExportController extends BaseController
if ($request->input(ENTITY_TASK)) {
$data['tasks'] = Task::scope()
->with('user', 'client.contacts')
->withTrashed()
->where('is_deleted', '=', false)
->withArchived()
->get();
}
if ($request->input(ENTITY_INVOICE)) {
$data['invoices'] = Invoice::scope()
->with('user', 'client.contacts', 'invoice_status')
->withTrashed()
->where('is_deleted', '=', false)
->withArchived()
->where('is_quote', '=', false)
->where('is_recurring', '=', false)
->get();
$data['quotes'] = Invoice::scope()
->with('user', 'client.contacts', 'invoice_status')
->withTrashed()
->where('is_deleted', '=', false)
->withArchived()
->where('is_quote', '=', true)
->where('is_recurring', '=', false)
->get();
$data['recurringInvoices'] = Invoice::scope()
->with('user', 'client.contacts', 'invoice_status', 'frequency')
->withArchived()
->where('is_quote', '=', false)
->where('is_recurring', '=', true)
->get();
}
if ($request->input(ENTITY_PAYMENT)) {
$data['payments'] = Payment::scope()
->withTrashed()
->where('is_deleted', '=', false)
->withArchived()
->with('user', 'client.contacts', 'payment_type', 'invoice', 'account_gateway.gateway')
->get();
}
@ -161,14 +163,14 @@ class ExportController extends BaseController
if ($request->input(ENTITY_VENDOR)) {
$data['clients'] = Vendor::scope()
->with('user', 'vendorcontacts', 'country')
->withTrashed()
->where('is_deleted', '=', false)
->withArchived()
->get();
$data['vendor_contacts'] = VendorContact::scope()
->with('user', 'vendor.contacts')
->withTrashed()
->get();
/*
$data['expenses'] = Credit::scope()
->with('user', 'client.contacts')

View File

@ -200,6 +200,11 @@ class Invoice extends EntityModel implements BalanceAffecting
return $this->hasMany('App\Models\Invoice', 'recurring_invoice_id');
}
public function frequency()
{
return $this->belongsTo('App\Models\Frequency');
}
public function invitations()
{
return $this->hasMany('App\Models\Invitation')->orderBy('invitations.contact_id');

View File

@ -40,9 +40,15 @@ class InvoicePresenter extends Presenter {
public function status()
{
$status = $this->entity->invoice_status ? $this->entity->invoice_status->name : 'draft';
$status = strtolower($status);
return trans("texts.status_{$status}");
if ($this->entity->is_deleted) {
return trans('texts.deleted');
} elseif ($this->entity->trashed()) {
return trans('texts.archived');
} else {
$status = $this->entity->invoice_status ? $this->entity->invoice_status->name : 'draft';
$status = strtolower($status);
return trans("texts.status_{$status}");
}
}
public function invoice_date()
@ -55,9 +61,19 @@ class InvoicePresenter extends Presenter {
return Utils::fromSqlDate($this->entity->due_date);
}
public function frequency()
{
return $this->entity->frequency ? $this->entity->frequency->name : '';
}
public function link()
{
return link_to('/invoices/' . $this->entity->public_id, $this->entity->invoice_number);
}
public function email()
{
$client = $this->entity->client;
return count($client->contacts) ? $client->contacts[0]->email : '';
}
}

View File

@ -81,7 +81,7 @@ $LANG = array(
'company_details' => 'Company Details',
'online_payments' => 'Online Payments',
'notifications' => 'Email Notifications',
'import_export' => 'Import/Export/Cancel',
'import_export' => 'Import | Export | Cancel',
'done' => 'Done',
'save' => 'Save',
'create' => 'Create',

View File

@ -35,6 +35,11 @@
@include('export.invoices', ['entityType' => ENTITY_QUOTE])
@endif
@if (isset($recurringInvoices) && $recurringInvoices && count($recurringInvoices))
<tr><td>{{ strtoupper(trans('texts.recurring_invoices')) }}</td></tr>
@include('export.recurring_invoices', ['entityType' => ENTITY_RECURRING_INVOICE])
@endif
@if (isset($payments) && $payments && count($payments))
<tr><td>{{ strtoupper(trans('texts.payments')) }}</td></tr>
@include('export.payments')

View File

@ -1,5 +1,6 @@
<tr>
<td>{{ trans('texts.client') }}</td>
<td>{{ trans('texts.email') }}</td>
@if ($multiUser)
<td>{{ trans('texts.user') }}</td>
@endif
@ -28,6 +29,7 @@
@if (!$invoice->client->is_deleted)
<tr>
<td>{{ $invoice->present()->client }}</td>
<td>{{ $invoice->present()->email }}</td>
@if ($multiUser)
<td>{{ $invoice->present()->user }}</td>
@endif