invoiceninja/app/Ninja/Datatables/ProposalSnippetDatatable.php

70 lines
1.9 KiB
PHP
Raw Normal View History

2018-01-30 20:58:55 +02:00
<?php
namespace App\Ninja\Datatables;
use Auth;
use URL;
use Utils;
class ProposalSnippetDatatable extends EntityDatatable
{
public $entityType = ENTITY_PROPOSAL_SNIPPET;
public $sortCol = 1;
public function columns()
{
return [
[
2018-02-04 18:47:55 +02:00
'name',
2018-01-30 20:58:55 +02:00
function ($model) {
2018-02-09 16:35:36 +02:00
$icon = '<i class="fa fa-' . $model->icon . '"></i>&nbsp;&nbsp;';
if (Auth::user()->can('view', [ENTITY_PROPOSAL_SNIPPET, $model]))
return $icon . link_to("proposals/snippets/{$model->public_id}/edit", $model->name)->toHtml();
else
2018-02-09 16:35:36 +02:00
return $icon . $model->name;
2018-01-30 20:58:55 +02:00
2018-02-04 17:31:45 +02:00
},
],
[
'category',
function ($model) {
if (Auth::user()->can('view', [ENTITY_PROPOSAL_CATEGORY, $model]))
return link_to("proposals/categories/{$model->category_public_id}/edit", $model->category ?: ' ')->toHtml();
else
2018-02-04 17:31:45 +02:00
return $model->category;
2018-01-30 20:58:55 +02:00
},
],
2018-02-04 23:50:57 +02:00
[
'content',
function ($model) {
return $this->showWithTooltip(strip_tags($model->content));
},
],
2018-02-04 18:42:13 +02:00
[
'private_notes',
function ($model) {
return $this->showWithTooltip($model->private_notes);
},
],
2018-01-30 20:58:55 +02:00
];
}
public function actions()
{
return [
[
2018-02-04 17:31:45 +02:00
trans('texts.edit_proposal_snippet'),
2018-01-30 20:58:55 +02:00
function ($model) {
2018-02-04 17:31:45 +02:00
return URL::to("proposals/snippets/{$model->public_id}/edit");
2018-01-30 20:58:55 +02:00
},
function ($model) {
return Auth::user()->can('view', [ENTITY_PROPOSAL_SNIPPET, $model]);
2018-01-30 20:58:55 +02:00
},
],
];
}
}