mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Payment methods list view
This commit is contained in:
parent
cc7ee120d5
commit
a926c48f21
@ -11,7 +11,7 @@
|
||||
|
||||
namespace App\Http\Controllers\ClientPortal;
|
||||
|
||||
use = namespace\Cache;
|
||||
use Cache;
|
||||
use App\Filters\PaymentFilters;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\CompanyGateway;
|
||||
|
@ -13,39 +13,54 @@ namespace App\Http\Controllers\ClientPortal;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\ClientGatewayToken;
|
||||
use App\Utils\Traits\MakesDates;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Yajra\DataTables\Facades\DataTables;
|
||||
use Yajra\DataTables\Html\Builder;
|
||||
|
||||
class PaymentMethodController extends Controller
|
||||
{
|
||||
use MakesDates;
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
public function index(Builder $builder)
|
||||
{
|
||||
$payment_methods = ClientGatewayToken::whereClientId(auth()->user()->client->id);
|
||||
$payment_methods->with('gateway_type');
|
||||
|
||||
if (request()->ajax()) {
|
||||
|
||||
return DataTables::of($payment_methods)->addColumn('action', function ($invoice) {
|
||||
return '<a href="/client/payment_methods/'. $payment_methods->hashed_id .'" class="btn btn-xs btn-primary"><i class="glyphicon glyphicon-edit"></i>'.ctrans('texts.view').'</a>';
|
||||
return DataTables::of($payment_methods)->addColumn('action', function ($payment_method) {
|
||||
return '<a href="/client/payment_methods/'. $payment_method->hashed_id .'" class="btn btn-xs btn-primary"><i class="glyphicon glyphicon-edit"></i>'.ctrans('texts.view').'</a>';
|
||||
})
|
||||
->editColumn('status_id', function ($invoice){
|
||||
return Invoice::badgeForStatus($invoice->status);
|
||||
})->editColumn('invoice_date', function ($invoice){
|
||||
return $this->formatDate($invoice->invoice_date, $invoice->client->date_format());
|
||||
})->editColumn('due_date', function ($invoice){
|
||||
return $this->formatDate($invoice->due_date, $invoice->client->date_format());
|
||||
})->editColumn('balance', function ($invoice) {
|
||||
return Number::formatMoney($invoice->balance, $invoice->client);
|
||||
})->editColumn('amount', function ($invoice) {
|
||||
return Number::formatMoney($invoice->amount, $invoice->client);
|
||||
->editColumn('gateway_type_id', function ($payment_method){
|
||||
return ctrans("texts.{$payment_method->gateway_type->alias}");
|
||||
})->editColumn('created_at', function ($payment_method){
|
||||
return $this->formatDate($payment_method->created_at, auth()->user()->client->date_format());
|
||||
})->editColumn('is_default', function ($payment_method){
|
||||
return $payment_method->is_default ? ctrans('texts.default') : '';
|
||||
})->editColumn('meta', function ($payment_method) {
|
||||
if(isset($payment_method->meta->exp_month) && isset($payment_method->meta->exp_year))
|
||||
return "{$payment_method->meta->exp_month}/{$payment_method->meta->exp_year}";
|
||||
else
|
||||
return "";
|
||||
})->addColumn('last4', function ($payment_method) {
|
||||
if(isset($payment_method->meta->last4))
|
||||
return $payment_method->meta->last4;
|
||||
else
|
||||
return "";
|
||||
})->addColumn('brand', function ($payment_method) {
|
||||
if(isset($payment_method->meta->brand))
|
||||
return $payment_method->meta->brand;
|
||||
else
|
||||
return "";
|
||||
})
|
||||
->rawColumns(['action', 'status_id'])
|
||||
->rawColumns(['action', 'status_id','last4','brand'])
|
||||
->make(true);
|
||||
|
||||
}
|
||||
|
@ -63,6 +63,7 @@ class PortalComposer
|
||||
$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'];
|
||||
$data[] = [ 'title' => ctrans('texts.payment_methods'), 'url' => 'client.payment_methods.index', 'icon' => 'fa fa-cc-stripe fa-fw fa-2x'];
|
||||
|
||||
return $data;
|
||||
|
||||
|
@ -36,7 +36,7 @@ class ClientGatewayToken extends BaseModel
|
||||
|
||||
public function gateway_type()
|
||||
{
|
||||
return $this->hasOne(GatewayType::class);
|
||||
return $this->hasOne(GatewayType::class, 'id','gateway_type_id');
|
||||
}
|
||||
|
||||
public function company()
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
<!-- Filters / Buttons in here.-->
|
||||
<div id="top_right_buttons" class="pull-right">
|
||||
<a href="{{ route('client.payment_methods.create ')}}" class="btn btn-success">{{ ctrans('texts.add_payment_method') }}</button>
|
||||
<a href="{{ route('client.payment_methods.create')}}" class="btn btn-success">{{ ctrans('texts.add_payment_method') }}</a>
|
||||
</div>
|
||||
|
||||
<div class="animated fadeIn">
|
||||
@ -69,25 +69,14 @@ $(function() {
|
||||
loadingRecords: "{{ trans('texts.loading') }}",
|
||||
zeroRecords: "{{ trans('texts.no_records_found') }}"
|
||||
},
|
||||
ajax: {
|
||||
url: '{!! route('client.payment_methods.index') !!}',
|
||||
data: function(data) {
|
||||
}
|
||||
|
||||
},
|
||||
drawCallback: function(settings){
|
||||
|
||||
data = this.api().ajax.json().data;
|
||||
|
||||
},
|
||||
columns: [
|
||||
|
||||
{data: 'invoice_number', name: 'invoice_number', title: '{{ctrans('texts.invoice_number')}}', visible: true},
|
||||
{data: 'invoice_date', name: 'invoice_date', title: '{{ctrans('texts.invoice_date')}}', visible: true},
|
||||
{data: 'amount', name: 'amount', title: '{{ctrans('texts.total')}}', visible: true},
|
||||
{data: 'balance', name: 'balance', title: '{{ctrans('texts.balance')}}', visible: true},
|
||||
{data: 'due_date', name: 'due_date', title: '{{ctrans('texts.due_date')}}', visible: true},
|
||||
{data: 'status_id', name: 'status_id', title: '{{ctrans('texts.status')}}', visible: true},
|
||||
{data: 'created_at', name: 'created_at', title: '{{ctrans('texts.created_at')}}', visible: true},
|
||||
{data: 'gateway_type_id', name: 'gateway_type_id', title: '{{ctrans('texts.payment_type_id')}}', visible: true},
|
||||
{data: 'brand', name: 'brand', title: '{{ctrans('texts.type')}}', visible: true},
|
||||
{data: 'meta', name: 'meta', title: '{{ctrans('texts.card_expiration')}}', visible: true},
|
||||
{data: 'last4', name: 'last4', title: '{{ctrans('texts.card_number')}}', visible: true},
|
||||
{data: 'is_default', name: 'is_default', title: '{{ctrans('texts.default')}}', visible: true},
|
||||
{data: 'action', name: 'action', title: '', searchable: false, orderable: false},
|
||||
]
|
||||
});
|
||||
@ -95,5 +84,4 @@ $(function() {
|
||||
|
||||
</script>
|
||||
|
||||
@endpush
|
||||
|
||||
@endpush
|
Loading…
x
Reference in New Issue
Block a user