diff --git a/app/Entities/Partners/Customer.php b/app/Entities/Partners/Customer.php index d1be026..48f7bb3 100644 --- a/app/Entities/Partners/Customer.php +++ b/app/Entities/Partners/Customer.php @@ -23,6 +23,11 @@ class Customer extends Model return $this->hasMany('App\Entities\Subscriptions\Subscription'); } + public function invoices() + { + return $this->hasManyThrough('App\Entities\Invoices\Invoice', 'App\Entities\Projects\Project'); + } + public function nameLink() { return link_to_route('customers.show', $this->name, [$this->id], [ diff --git a/app/Http/Controllers/Customers/InvoicesController.php b/app/Http/Controllers/Customers/InvoicesController.php new file mode 100644 index 0000000..67e4a04 --- /dev/null +++ b/app/Http/Controllers/Customers/InvoicesController.php @@ -0,0 +1,21 @@ + + */ +class InvoicesController extends Controller +{ + public function index(Customer $customer) + { + $invoices = $customer->invoices()->orderBy('due_date')->get(); + + return view('customers.invoices', compact('customer', 'invoices')); + } +} diff --git a/resources/lang/en/customer.php b/resources/lang/en/customer.php index 9b52ef1..9043d54 100644 --- a/resources/lang/en/customer.php +++ b/resources/lang/en/customer.php @@ -35,4 +35,5 @@ return [ 'projects' => 'Project List', 'payments' => 'Payment History', 'subscriptions' => 'Subscription List', + 'invoices' => 'Invoice List', ]; diff --git a/resources/lang/id/customer.php b/resources/lang/id/customer.php index 8014972..fc896a3 100644 --- a/resources/lang/id/customer.php +++ b/resources/lang/id/customer.php @@ -35,4 +35,5 @@ return [ 'projects' => 'List Project', 'payments' => 'History Pembayaran', 'subscriptions' => 'List Langganan', + 'invoices' => 'List Invoice', ]; diff --git a/resources/views/customers/invoices.blade.php b/resources/views/customers/invoices.blade.php new file mode 100755 index 0000000..26be3b4 --- /dev/null +++ b/resources/views/customers/invoices.blade.php @@ -0,0 +1,58 @@ +@extends('layouts.customer') + +@section('title', trans('invoice.list')) + +@section('content-customer') +
| {{ trans('app.table_no') }} | +{{ trans('invoice.number') }} | +{{ trans('app.date') }} | +{{ trans('project.project') }} | +{{ trans('invoice.customer') }} | +{{ trans('invoice.amount') }} | +{{ trans('app.action') }} | + + + @forelse($invoices as $key => $invoice) +
|---|---|---|---|---|---|---|
| {{ 1 + $key }} | +{{ $invoice->numberLink() }} | +{{ $invoice->created_at->format('Y-m-d') }} | +{{ $invoice->project->nameLink() }} | +{{ $invoice->project->customer->nameLink() }} | +{{ formatRp($invoice->amount) }} | ++ {!! html_link_to_route( + 'invoices.show', '', [$invoice->number], + [ + 'icon' => 'search', + 'class' => 'btn btn-info btn-xs', + 'title' => 'Lihat ' . trans('invoice.show') + ] + ) !!} + {!! html_link_to_route( + 'invoices.pdf', '', [$invoice->number], + [ + 'icon' => 'print', + 'class' => 'btn btn-default btn-xs', + 'title' => trans('invoice.print'), 'target' => '_blank' + ] + ) !!} + | +
| {{ trans('invoice.empty') }} | ||||||
| {{ trans('app.total') }} | +{{ formatRp($invoices->sum('amount')) }} | ++ | ||||