invoiceninja/app/Ninja/Datatables/RecurringInvoiceDatatable.php

84 lines
2.3 KiB
PHP
Raw Normal View History

2017-01-30 21:40:43 +02:00
<?php
namespace App\Ninja\Datatables;
2016-05-23 19:52:20 +03:00
use Auth;
2017-01-30 21:40:43 +02:00
use URL;
use Utils;
2016-05-23 19:52:20 +03:00
class RecurringInvoiceDatatable extends EntityDatatable
{
public $entityType = ENTITY_RECURRING_INVOICE;
public function columns()
{
return [
[
'frequency',
function ($model) {
$frequency = strtolower($model->frequency);
$frequency = preg_replace('/\s/', '_', $frequency);
2017-01-30 21:40:43 +02:00
return link_to("invoices/{$model->public_id}", trans('texts.freq_'.$frequency))->toHtml();
2017-01-30 21:40:43 +02:00
},
2016-05-23 19:52:20 +03:00
],
[
'client_name',
function ($model) {
return link_to("clients/{$model->client_public_id}", Utils::getClientDisplayName($model))->toHtml();
},
2017-01-30 21:40:43 +02:00
! $this->hideClient,
2016-05-23 19:52:20 +03:00
],
[
'start_date',
function ($model) {
return Utils::fromSqlDate($model->start_date);
2017-01-30 21:40:43 +02:00
},
2016-05-23 19:52:20 +03:00
],
[
'last_sent',
function ($model) {
return Utils::fromSqlDate($model->last_sent_date);
2017-01-30 21:40:43 +02:00
},
],
2016-05-23 19:52:20 +03:00
[
'end_date',
function ($model) {
return Utils::fromSqlDate($model->end_date);
2017-01-30 21:40:43 +02:00
},
2016-05-23 19:52:20 +03:00
],
[
'amount',
function ($model) {
return Utils::formatMoney($model->amount, $model->currency_id, $model->country_id);
2017-01-30 21:40:43 +02:00
},
],
2016-05-23 19:52:20 +03:00
];
}
public function actions()
{
return [
[
trans('texts.edit_invoice'),
function ($model) {
return URL::to("invoices/{$model->public_id}/edit");
},
function ($model) {
return Auth::user()->can('editByOwner', [ENTITY_INVOICE, $model->user_id]);
2017-01-30 21:40:43 +02:00
},
2016-09-26 09:54:59 +03:00
],
[
2017-01-30 21:40:43 +02:00
trans('texts.clone_invoice'),
2016-09-26 09:54:59 +03:00
function ($model) {
return URL::to("invoices/{$model->public_id}/clone");
},
function ($model) {
return Auth::user()->can('create', ENTITY_INVOICE);
2017-01-30 21:40:43 +02:00
},
2016-09-26 09:54:59 +03:00
],
2016-05-23 19:52:20 +03:00
];
}
}