diff --git a/app/Filters/PaymentFilters.php b/app/Filters/PaymentFilters.php index edb348d451b1..4b9c80269056 100644 --- a/app/Filters/PaymentFilters.php +++ b/app/Filters/PaymentFilters.php @@ -35,7 +35,9 @@ class PaymentFilters extends QueryFilters return $this->builder; return $this->builder->where(function ($query) use ($filter) { - $query->where('payments.custom_value1', 'like', '%'.$filter.'%') + $query->where('payments.amount', 'like', '%'.$filter.'%') + ->orWhere('payments.payment_date', 'like', '%'.$filter.'%') + ->orWhere('payments.custom_value1', 'like', '%'.$filter.'%') ->orWhere('payments.custom_value2', 'like' , '%'.$filter.'%') ->orWhere('payments.custom_value3', 'like' , '%'.$filter.'%') ->orWhere('payments.custom_value4', 'like' , '%'.$filter.'%'); @@ -113,8 +115,26 @@ class PaymentFilters extends QueryFilters public function entityFilter() { - return $this->builder->whereCompanyId(auth()->user()->company()->id); - + if(auth('contact')->user()) + return $this->contactViewFilter(); + else + return $this->builder->whereCompanyId(auth()->user()->company()->id); } -} \ No newline at end of file + + + /** + * 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) + ->whereIsDeleted(false); + + } +} diff --git a/app/Http/Controllers/ClientPortal/PaymentController.php b/app/Http/Controllers/ClientPortal/PaymentController.php new file mode 100644 index 000000000000..28142ce5565d --- /dev/null +++ b/app/Http/Controllers/ClientPortal/PaymentController.php @@ -0,0 +1,80 @@ +ajax()) { + + return DataTables::of($payments)->addColumn('action', function ($payment) { + return ''.ctrans('texts.view').''; + })->editColumn('payment_type_id', function ($payment) { + return Payment::typeForKey($payment->payment_type_id); + }) + ->editColumn('status_id', function ($payment){ + return Payment::badgeForStatus($invoice->status); + }) + ->rawColumns(['action', 'status_id']) + ->make(true); + + } + + $data['html'] = $builder; + + return view('portal.default.payments.index', $data); + + } + + /** + * Display the specified resource. + * + * @param \App\Models\Invoice $invoice The invoice + * + * @return \Illuminate\Http\Response + */ + public function show(RecurringInvoice $invoice) + { + + + } + + + +} diff --git a/app/Http/ViewComposers/PortalComposer.php b/app/Http/ViewComposers/PortalComposer.php index b5926acdb1fc..97010d17d5f8 100644 --- a/app/Http/ViewComposers/PortalComposer.php +++ b/app/Http/ViewComposers/PortalComposer.php @@ -60,6 +60,7 @@ class PortalComposer $data[] = [ 'title' => ctrans('texts.dashboard'), 'url' => 'client.dashboard', 'icon' => 'fa fa-tachometer fa-fw fa-2x']; $data[] = [ 'title' => ctrans('texts.invoices'), 'url' => 'client.invoices.index', 'icon' => 'fa fa-file-pdf-o fa-fw fa-2x']; $data[] = [ 'title' => ctrans('texts.recurring_invoices'), 'url' => 'client.recurring_invoices.index', 'icon' => 'fa fa-files-o fa-fw fa-2x']; + $data[] = [ 'title' => ctrans('texts.payments'), 'url' => 'client.payments.index', 'icon' => 'fa fa-credit-card fa-fw fa-2x']; return $data; diff --git a/app/Models/Payment.php b/app/Models/Payment.php index 6e272c874121..577493869e83 100644 --- a/app/Models/Payment.php +++ b/app/Models/Payment.php @@ -64,4 +64,22 @@ class Payment extends BaseModel { return $this->morphMany(CompanyLedger::class, 'company_ledgerable'); } + + public static function typeForId(int $payment_type_id) + { + + } + + public static function badgeForStatus(int $status) + { + switch ($status) { + case 'value': + # code... + break; + + default: + # code... + break; + } + } } diff --git a/resources/views/portal/default/payments/index.blade.php b/resources/views/portal/default/payments/index.blade.php new file mode 100644 index 000000000000..9553efcc7e1b --- /dev/null +++ b/resources/views/portal/default/payments/index.blade.php @@ -0,0 +1,82 @@ +@extends('portal.default.layouts.master') +@section('header') + @parent + +@stop +@section('body') +
+
+ +
+ +
+ +
+
+ + {!! $html->table(['class' => 'table table-hover table-striped', 'id' => 'datatable'], true) !!} + +
+
+
+ +
+ +
+
+ +@endsection +@push('scripts') + + +@endpush +@section('footer') + +@endsection + diff --git a/routes/client.php b/routes/client.php index 8cd4a4896fd7..ba4a7a11edc3 100644 --- a/routes/client.php +++ b/routes/client.php @@ -20,6 +20,8 @@ Route::group(['middleware' => ['auth:contact'], 'prefix' => 'client', 'as' => 'c Route::post('invoices/payment', 'ClientPortal\InvoiceController@bulk')->name('invoices.bulk'); Route::get('recurring_invoices', 'ClientPortal\RecurringInvoiceController@index')->name('recurring_invoices.index'); + + Route::get('payments', 'ClientPortal\PaymentController@index')->name('payments.index'); Route::get('profile/{client_contact}/edit', 'ClientPortal\ProfileController@edit')->name('profile.edit');