1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-14 23:22:52 +01:00
invoiceninja/app/Ninja/Datatables/CreditDatatable.php

81 lines
2.5 KiB
PHP
Raw Normal View History

2016-07-21 14:35:23 +02:00
<?php namespace App\Ninja\Datatables;
2016-05-23 18:52:20 +02:00
use Utils;
use URL;
use Auth;
class CreditDatatable extends EntityDatatable
{
public $entityType = ENTITY_CREDIT;
2016-11-24 10:41:11 +01:00
public $sortCol = 4;
2016-11-30 19:21:50 +01:00
2016-05-23 18:52:20 +02:00
public function columns()
{
return [
[
'client_name',
function ($model) {
if(!Auth::user()->can('viewByOwner', [ENTITY_CLIENT, $model->client_user_id])){
return Utils::getClientDisplayName($model);
}
return $model->client_public_id ? link_to("clients/{$model->client_public_id}", Utils::getClientDisplayName($model))->toHtml() : '';
},
! $this->hideClient
],
[
'amount',
function ($model) {
return Utils::formatMoney($model->amount, $model->currency_id, $model->country_id) . '<span '.Utils::getEntityRowClass($model).'/>';
}
],
[
'balance',
function ($model) {
return Utils::formatMoney($model->balance, $model->currency_id, $model->country_id);
}
],
[
'credit_date',
function ($model) {
2016-12-04 11:24:48 +01:00
if ( ! Auth::user()->can('viewByOwner', [ENTITY_CREDIT, $model->user_id])){
return Utils::fromSqlDate($model->credit_date);
}
return link_to("credits/{$model->public_id}/edit", Utils::fromSqlDate($model->credit_date))->toHtml();
2016-05-23 18:52:20 +02:00
}
],
[
'private_notes',
function ($model) {
return $model->private_notes;
}
]
];
}
public function actions()
{
return [
2016-11-30 19:21:50 +01:00
[
trans('texts.edit_credit'),
function ($model) {
return URL::to("credits/{$model->public_id}/edit");
},
function ($model) {
return Auth::user()->can('editByOwner', [ENTITY_CREDIT, $model->user_id]);
}
],
2016-05-23 18:52:20 +02:00
[
trans('texts.apply_credit'),
function ($model) {
return URL::to("payments/create/{$model->client_public_id}") . '?paymentTypeId=1';
},
2016-07-21 14:35:23 +02:00
function ($model) {
2016-05-23 18:52:20 +02:00
return Auth::user()->can('create', ENTITY_PAYMENT);
}
]
];
}
}