invoiceninja/app/Ninja/Datatables/ProposalTemplateDatatable.php

74 lines
2.1 KiB
PHP
Raw Permalink Normal View History

2018-01-30 20:58:55 +02:00
<?php
namespace App\Ninja\Datatables;
use Auth;
use URL;
use Utils;
class ProposalTemplateDatatable extends EntityDatatable
{
public $entityType = ENTITY_PROPOSAL_TEMPLATE;
public $sortCol = 1;
public function columns()
{
return [
[
2018-02-04 18:42:13 +02:00
'name',
2018-01-30 20:58:55 +02:00
function ($model) {
if (Auth::user()->can('view', [ENTITY_PROPOSAL_TEMPLATE, $model]))
return link_to("proposals/templates/{$model->public_id}", $model->name)->toHtml();
else
2018-01-30 20:58:55 +02:00
return $model->name;
},
],
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 18:42:13 +02:00
trans('texts.edit_proposal_template'),
2018-01-30 20:58:55 +02:00
function ($model) {
2018-02-04 18:42:13 +02:00
return URL::to("proposals/templates/{$model->public_id}/edit");
2018-01-30 20:58:55 +02:00
},
2019-01-30 22:00:26 +11:00
function ($model) {$model->entityType = ENTITY_PROPOSAL;
return Auth::user()->can('viewModel', $model) ;
2018-01-30 20:58:55 +02:00
},
],
2018-02-08 13:41:22 +02:00
[
trans('texts.clone_proposal_template'),
function ($model) {
return URL::to("proposals/templates/{$model->public_id}/clone");
},
function ($model) {
return Auth::user()->can('view', [ENTITY_PROPOSAL_TEMPLATE, $model]);
2018-02-08 13:41:22 +02:00
},
],
2018-02-09 16:02:28 +02:00
[
trans('texts.new_proposal'),
function ($model) {
return URL::to("proposals/create/0/{$model->public_id}");
},
function ($model) {
2019-01-30 22:00:26 +11:00
return Auth::user()->can('createEntity', ENTITY_PROPOSAL);
2018-02-09 16:02:28 +02:00
},
],
2018-01-30 20:58:55 +02:00
];
}
}