mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Client Portal Payments List View
This commit is contained in:
parent
0892993afe
commit
c2441bdef0
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
}
|
||||
}
|
||||
|
80
app/Http/Controllers/ClientPortal/PaymentController.php
Normal file
80
app/Http/Controllers/ClientPortal/PaymentController.php
Normal file
@ -0,0 +1,80 @@
|
||||
<?php
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com)
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2019. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://opensource.org/licenses/AAL
|
||||
*/
|
||||
|
||||
namespace App\Http\Controllers\ClientPortal;
|
||||
|
||||
use App\Filters\PaymentFilters;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Payment;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Yajra\DataTables\Facades\DataTables;
|
||||
use Yajra\DataTables\Html\Builder;
|
||||
|
||||
/**
|
||||
* Class InvoiceController
|
||||
* @package App\Http\Controllers\ClientPortal\InvoiceController
|
||||
*/
|
||||
|
||||
class PaymentController extends Controller
|
||||
{
|
||||
|
||||
use MakesHash;
|
||||
|
||||
/**
|
||||
* Show the list of Invoices
|
||||
*
|
||||
* @param \App\Filters\InvoiceFilters $filters The filters
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index(PaymentFilters $filters, Builder $builder)
|
||||
{
|
||||
$payments = Payment::filter($filters);
|
||||
|
||||
if (request()->ajax()) {
|
||||
|
||||
return DataTables::of($payments)->addColumn('action', function ($payment) {
|
||||
return '<a href="/client/payments/'. $payment->hashed_id .'/edit" class="btn btn-xs btn-primary"><i class="glyphicon glyphicon-edit"></i>'.ctrans('texts.view').'</a>';
|
||||
})->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)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
82
resources/views/portal/default/payments/index.blade.php
Normal file
82
resources/views/portal/default/payments/index.blade.php
Normal file
@ -0,0 +1,82 @@
|
||||
@extends('portal.default.layouts.master')
|
||||
@section('header')
|
||||
@parent
|
||||
<link href="//cdn.datatables.net/1.10.19/css/dataTables.bootstrap4.min.css" rel="stylesheet" type="text/css"/>
|
||||
@stop
|
||||
@section('body')
|
||||
<main class="main">
|
||||
<div class="container-fluid">
|
||||
|
||||
<div class="row" style="padding-top: 30px;">
|
||||
|
||||
<div class="col-lg-12" style="padding-bottom: 10px;">
|
||||
|
||||
<div class="animated fadeIn">
|
||||
<div class="col-md-12 card">
|
||||
|
||||
{!! $html->table(['class' => 'table table-hover table-striped', 'id' => 'datatable'], true) !!}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</main>
|
||||
</body>
|
||||
@endsection
|
||||
@push('scripts')
|
||||
<script src="//cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js" type="text/javascript"></script>
|
||||
<script src="//cdn.datatables.net/1.10.18/js/dataTables.bootstrap4.min.js"></script>
|
||||
@endpush
|
||||
@section('footer')
|
||||
<script>
|
||||
|
||||
/*global json payload*/
|
||||
var data;
|
||||
|
||||
var data_table;
|
||||
|
||||
$(function() {
|
||||
|
||||
data_table = $('#datatable').DataTable({
|
||||
processing: true,
|
||||
serverSide: true,
|
||||
searching: false,
|
||||
bLengthChange: false,
|
||||
language: {
|
||||
processing: " {{ trans('texts.processing_request') }}",
|
||||
search: "{{ trans('texts.search') }}:",
|
||||
// info: "{{ trans('texts.info') }}",
|
||||
infoPostFix: "",
|
||||
loadingRecords: "{{ trans('texts.loading') }}",
|
||||
zeroRecords: "{{ trans('texts.no_records_found') }}"
|
||||
},
|
||||
ajax: {
|
||||
url: '{!! route('client.recurring_invoices.index') !!}',
|
||||
data: function(data) {
|
||||
}
|
||||
|
||||
},
|
||||
drawCallback: function(settings){
|
||||
|
||||
data = this.api().ajax.json().data;
|
||||
|
||||
},
|
||||
columns: [
|
||||
|
||||
{data: 'payment_date', name: 'payment_date', title: '{{trans('texts.payment_date')}}', visible: true},
|
||||
{data: 'payment_type_id', name: 'payment_type_id', title: '{{trans('texts.payment_type_id')}}', visible: true},
|
||||
{data: 'amount', name: 'amount', title: '{{trans('texts.amount')}}', visible: true},
|
||||
{data: 'status_id', name: 'status_id', title: '{{trans('texts.status')}}', visible: true},
|
||||
{data: 'transaction_reference', name: 'transaction_reference', title: '{{trans('texts.transaction_reference')}}', visible: true},
|
||||
{data: 'action', name: 'action', title: '', searchable: false, orderable: false},
|
||||
|
||||
]
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
@endsection
|
||||
|
@ -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');
|
||||
|
Loading…
x
Reference in New Issue
Block a user