diff --git a/app/Http/Controllers/ExportController.php b/app/Http/Controllers/ExportController.php index 540e38d97296..a7f5db4b577d 100644 --- a/app/Http/Controllers/ExportController.php +++ b/app/Http/Controllers/ExportController.php @@ -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') diff --git a/app/Models/Invoice.php b/app/Models/Invoice.php index 835de501c67d..e60a06f8d4a4 100644 --- a/app/Models/Invoice.php +++ b/app/Models/Invoice.php @@ -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'); diff --git a/app/Ninja/Presenters/InvoicePresenter.php b/app/Ninja/Presenters/InvoicePresenter.php index 2bab049d2a31..0daa73312386 100644 --- a/app/Ninja/Presenters/InvoicePresenter.php +++ b/app/Ninja/Presenters/InvoicePresenter.php @@ -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 : ''; + } } \ No newline at end of file diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index d130919802a7..d98821b83fee 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -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', diff --git a/resources/views/export.blade.php b/resources/views/export.blade.php index f2fa8dbbe7fe..6625dee11c5a 100644 --- a/resources/views/export.blade.php +++ b/resources/views/export.blade.php @@ -35,6 +35,11 @@ @include('export.invoices', ['entityType' => ENTITY_QUOTE]) @endif + @if (isset($recurringInvoices) && $recurringInvoices && count($recurringInvoices)) +