diff --git a/app/Filters/InvoiceFilters.php b/app/Filters/InvoiceFilters.php index 25bb8e2ae9fe..3897ea3b0b08 100644 --- a/app/Filters/InvoiceFilters.php +++ b/app/Filters/InvoiceFilters.php @@ -11,6 +11,7 @@ namespace App\Filters; +use App\Models\Invoice; use App\Models\User; use Illuminate\Database\Eloquent\Builder; @@ -113,16 +114,31 @@ class InvoiceFilters extends QueryFilters * @param $company_id The company Id * @return Illuminate\Database\Query\Builder */ - public function entityFilter() + public function entityFilter() { if(auth('contact')->user()) - return $this->builder->whereCompanyId(auth('contact')->user()->company->id); + return $this->contactViewFilter(); else return $this->builder->whereCompanyId(auth()->user()->company()->id); } + /** + * We need additional filters when showing invoices for the + * client portal. Need to automatically exclude drafts and cancelled invoices + * + * @return Illuminate\Database\Query\Builder + */ + private function contactViewFilter() : Builder + { + + return $this->builder + ->whereCompanyId(auth('contact')->user()->company->id) + ->whereNotIn('status_id', [Invoice::STATUS_DRAFT, Invoice::STATUS_CANCELLED]); + + } + } \ No newline at end of file diff --git a/app/Http/Controllers/ClientPortal/InvoiceController.php b/app/Http/Controllers/ClientPortal/InvoiceController.php new file mode 100644 index 000000000000..ecdd48133d51 --- /dev/null +++ b/app/Http/Controllers/ClientPortal/InvoiceController.php @@ -0,0 +1,85 @@ +listResponse($invoices); + + } + + /** + * Display the specified resource. + * + * @param \App\Models\Invoice $invoice The invoice + * + * @return \Illuminate\Http\Response + */ + public function show(Invoice $invoice) + { + + + } + + /** + * Perform bulk actions on the list view + * + * @return Collection + */ + public function bulk() + { + + + } + + + +} diff --git a/app/Http/ViewComposers/PortalComposer.php b/app/Http/ViewComposers/PortalComposer.php index 74d476c1d515..84c5bde777e6 100644 --- a/app/Http/ViewComposers/PortalComposer.php +++ b/app/Http/ViewComposers/PortalComposer.php @@ -26,23 +26,36 @@ class PortalComposer * @param View $view * @return void */ - public function compose(View $view) + public function compose(View $view) :void { - $view->with('header', $this->portalData()); + $view->with('portal', $this->portalData()); } /** * @return array */ - private function portalData() + private function portalData() :array { if(!auth()->user()) return []; - $data = []; + $data['sidebar'] = $this->sidebarMenu(); + $data['header'] = []; + $data['footer'] = []; return $data; } + private function sidebarMenu() :array + { + + $data = []; + + $data[] = [ 'title' => ctrans('texts.dashboard'), 'url' => 'client.dashboard', 'icon' => 'fa fa-tachometer']; + $data[] = [ 'title' => ctrans('texts.invoices'), 'url' => 'client.invoices.index', 'icon' => 'fa fa-file-excel-o']; + + return $data; + } + } \ No newline at end of file diff --git a/app/Models/Presenters/ClientContactPresenter.php b/app/Models/Presenters/ClientContactPresenter.php index 19162fabda70..2f0f2d9c1695 100644 --- a/app/Models/Presenters/ClientContactPresenter.php +++ b/app/Models/Presenters/ClientContactPresenter.php @@ -18,4 +18,12 @@ namespace App\Models\Presenters; class ClientContactPresenter extends EntityPresenter { + /** + * @return string + */ + public function name() + { + return $this->entity->first_name . ' ' . $this->entity->last_name; + } + } diff --git a/resources/views/portal/default/header.blade.php b/resources/views/portal/default/header.blade.php index 64e2912bab1d..36b83cac3871 100644 --- a/resources/views/portal/default/header.blade.php +++ b/resources/views/portal/default/header.blade.php @@ -14,12 +14,12 @@ - - diff --git a/resources/views/portal/default/layouts/master.blade.php b/resources/views/portal/default/layouts/master.blade.php index e2fcd44056fb..f6de9bffa6ac 100644 --- a/resources/views/portal/default/layouts/master.blade.php +++ b/resources/views/portal/default/layouts/master.blade.php @@ -45,7 +45,7 @@ @yield('head') -@include('portal.default.header', $header) +@include('portal.default.header') @yield('header') @include('portal.default.sidebar') diff --git a/resources/views/portal/default/sidebar.blade.php b/resources/views/portal/default/sidebar.blade.php index b368e4f08334..d8713fcb8d73 100644 --- a/resources/views/portal/default/sidebar.blade.php +++ b/resources/views/portal/default/sidebar.blade.php @@ -2,67 +2,13 @@