2016-07-14 22:37:04 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Ninja\Datatables;
|
2016-05-23 18:52:20 +02:00
|
|
|
|
|
|
|
use Utils;
|
|
|
|
use URL;
|
|
|
|
use Auth;
|
|
|
|
|
2016-07-14 22:37:04 +02:00
|
|
|
/**
|
|
|
|
* Class RecurringInvoiceDatatable
|
|
|
|
*/
|
2016-05-23 18:52:20 +02:00
|
|
|
class RecurringInvoiceDatatable extends EntityDatatable
|
|
|
|
{
|
|
|
|
public $entityType = ENTITY_RECURRING_INVOICE;
|
|
|
|
|
2016-07-14 22:37:04 +02:00
|
|
|
/**
|
|
|
|
* @return array
|
|
|
|
*/
|
2016-05-23 18:52:20 +02:00
|
|
|
public function columns()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
[
|
|
|
|
'frequency',
|
|
|
|
function ($model) {
|
2016-07-01 23:19:09 +02:00
|
|
|
$frequency = strtolower($model->frequency);
|
|
|
|
$frequency = preg_replace('/\s/', '_', $frequency);
|
2016-07-02 23:18:13 +02:00
|
|
|
return link_to("invoices/{$model->public_id}", trans('texts.freq_'.$frequency))->toHtml();
|
2016-05-23 18:52:20 +02:00
|
|
|
}
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'client_name',
|
|
|
|
function ($model) {
|
|
|
|
return link_to("clients/{$model->client_public_id}", Utils::getClientDisplayName($model))->toHtml();
|
|
|
|
},
|
|
|
|
! $this->hideClient
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'start_date',
|
|
|
|
function ($model) {
|
|
|
|
return Utils::fromSqlDate($model->start_date);
|
|
|
|
}
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'end_date',
|
|
|
|
function ($model) {
|
|
|
|
return Utils::fromSqlDate($model->end_date);
|
|
|
|
}
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'amount',
|
|
|
|
function ($model) {
|
|
|
|
return Utils::formatMoney($model->amount, $model->currency_id, $model->country_id);
|
|
|
|
}
|
|
|
|
]
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2016-07-14 22:37:04 +02:00
|
|
|
/**
|
|
|
|
* @return array
|
|
|
|
*/
|
2016-05-23 18:52:20 +02: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]);
|
|
|
|
}
|
|
|
|
]
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|