1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-14 15:13:29 +01:00
invoiceninja/app/Ninja/Datatables/ProjectDatatable.php

87 lines
2.6 KiB
PHP
Raw Normal View History

2017-01-30 20:40:43 +01:00
<?php
namespace App\Ninja\Datatables;
2016-11-29 18:47:26 +01:00
use Auth;
2017-01-30 20:40:43 +01:00
use URL;
use Utils;
2016-11-29 18:47:26 +01:00
class ProjectDatatable extends EntityDatatable
{
public $entityType = ENTITY_PROJECT;
public $sortCol = 1;
public function columns()
{
return [
[
'project',
2017-01-30 17:05:31 +01:00
function ($model) {
if (! Auth::user()->can('editByOwner', [ENTITY_PROJECT, $model->user_id])) {
2016-11-29 18:47:26 +01:00
return $model->project;
}
2017-12-24 18:47:49 +01:00
$str = link_to("projects/{$model->public_id}", $model->project)->toHtml();
2017-12-24 16:23:43 +01:00
return $this->addNote($str, $model->private_notes);
2017-01-30 20:40:43 +01:00
},
2016-11-29 18:47:26 +01:00
],
[
'client_name',
2017-01-30 17:05:31 +01:00
function ($model) {
2016-11-29 18:47:26 +01:00
if ($model->client_public_id) {
2017-01-30 20:40:43 +01:00
if (! Auth::user()->can('viewByOwner', [ENTITY_CLIENT, $model->client_user_id])) {
2016-11-29 18:47:26 +01:00
return Utils::getClientDisplayName($model);
}
2017-12-31 22:24:57 +01:00
return link_to("clients/{$model->client_public_id}", $model->client_name)->toHtml();
2016-11-29 18:47:26 +01:00
} else {
return '';
}
2017-01-30 20:40:43 +01:00
},
],
2017-12-24 16:23:43 +01:00
[
'due_date',
function ($model) {
return Utils::fromSqlDate($model->due_date);
},
],
[
'budgeted_hours',
function ($model) {
2017-12-24 20:01:17 +01:00
return $model->budgeted_hours ?: '';
2017-12-24 16:23:43 +01:00
},
],
[
'task_rate',
function ($model) {
2017-12-24 20:01:17 +01:00
return floatval($model->task_rate) ? Utils::formatMoney($model->task_rate) : '';
}
],
2016-11-29 18:47:26 +01:00
];
}
public function actions()
{
return [
[
trans('texts.edit_project'),
function ($model) {
2017-01-30 20:40:43 +01:00
return URL::to("projects/{$model->public_id}/edit");
2016-11-29 18:47:26 +01:00
},
function ($model) {
return Auth::user()->can('editByOwner', [ENTITY_PROJECT, $model->user_id]);
2017-01-30 20:40:43 +01:00
},
2016-11-29 18:47:26 +01:00
],
[
trans('texts.invoice_project'),
function ($model) {
return "javascript:submitForm_project('invoice', {$model->public_id})";
},
function ($model) {
return Auth::user()->can('create', ENTITY_INVOICE);
},
],
2016-11-29 18:47:26 +01:00
];
}
}