invoiceninja/app/Ninja/Datatables/ProposalDatatable.php

87 lines
2.7 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 ProposalDatatable extends EntityDatatable
{
public $entityType = ENTITY_PROPOSAL;
public $sortCol = 1;
public function columns()
{
return [
[
'quote',
function ($model) {
2018-02-07 16:16:31 +02:00
if (! Auth::user()->can('viewByOwner', [ENTITY_QUOTE, $model->invoice_user_id])) {
return $model->invoice_number;
2018-01-30 20:58:55 +02:00
}
2018-02-07 16:16:31 +02:00
return link_to("quotes/{$model->invoice_public_id}", $model->invoice_number)->toHtml();
2018-01-30 20:58:55 +02:00
},
],
2018-02-11 11:14:47 +02:00
[
'client',
function ($model) {
if (! Auth::user()->can('viewByOwner', [ENTITY_CLIENT, $model->client_user_id])) {
return $model->client;
}
return link_to("clients/{$model->client_public_id}", $model->client)->toHtml();
},
],
2018-01-30 20:58:55 +02:00
[
'template',
function ($model) {
2018-02-04 18:42:13 +02:00
if (! Auth::user()->can('viewByOwner', [ENTITY_PROPOSAL_TEMPLATE, $model->template_user_id])) {
2018-02-08 09:39:19 +02:00
return $model->template ?: ' ';
2018-02-04 18:42:13 +02:00
}
2018-02-08 09:39:19 +02:00
return link_to("proposals/templates/{$model->template_public_id}/edit", $model->template ?: ' ')->toHtml();
2018-01-30 20:58:55 +02:00
},
],
[
2018-02-04 18:42:13 +02:00
'created_at',
2018-01-30 20:58:55 +02:00
function ($model) {
2018-02-04 18:42:13 +02:00
if (! Auth::user()->can('viewByOwner', [ENTITY_PROPOSAL, $model->user_id])) {
return Utils::timestampToDateString(strtotime($model->created_at));
}
return link_to("proposals/{$model->public_id}/edit", Utils::timestampToDateString(strtotime($model->created_at)))->toHtml();
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-01-30 20:58:55 +02:00
[
2018-02-04 18:42:13 +02:00
'private_notes',
2018-01-30 20:58:55 +02:00
function ($model) {
2018-02-04 18:42:13 +02:00
return $this->showWithTooltip($model->private_notes);
2018-01-30 20:58:55 +02:00
},
],
];
}
public function actions()
{
return [
[
trans('texts.edit_proposal'),
function ($model) {
return URL::to("proposals/{$model->public_id}/edit");
},
function ($model) {
return Auth::user()->can('editByOwner', [ENTITY_PROPOSAL, $model->user_id]);
},
],
];
}
}