2017-01-30 20:40:43 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Ninja\Datatables;
|
2016-05-23 18:52:20 +02:00
|
|
|
|
|
|
|
use Auth;
|
2017-01-30 20:40:43 +01:00
|
|
|
use URL;
|
|
|
|
use Utils;
|
2016-05-23 18:52:20 +02:00
|
|
|
|
|
|
|
class VendorDatatable extends EntityDatatable
|
|
|
|
{
|
|
|
|
public $entityType = ENTITY_VENDOR;
|
2016-11-24 10:46:57 +01:00
|
|
|
public $sortCol = 4;
|
2016-05-23 18:52:20 +02:00
|
|
|
|
|
|
|
public function columns()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
[
|
|
|
|
'name',
|
|
|
|
function ($model) {
|
|
|
|
return link_to("vendors/{$model->public_id}", $model->name ?: '')->toHtml();
|
2017-01-30 20:40:43 +01:00
|
|
|
},
|
2016-05-23 18:52:20 +02:00
|
|
|
],
|
|
|
|
[
|
|
|
|
'city',
|
|
|
|
function ($model) {
|
|
|
|
return $model->city;
|
2017-01-30 20:40:43 +01:00
|
|
|
},
|
2016-05-23 18:52:20 +02:00
|
|
|
],
|
|
|
|
[
|
|
|
|
'work_phone',
|
|
|
|
function ($model) {
|
|
|
|
return $model->work_phone;
|
2017-01-30 20:40:43 +01:00
|
|
|
},
|
2016-05-23 18:52:20 +02:00
|
|
|
],
|
|
|
|
[
|
|
|
|
'email',
|
|
|
|
function ($model) {
|
|
|
|
return link_to("vendors/{$model->public_id}", $model->email ?: '')->toHtml();
|
2017-01-30 20:40:43 +01:00
|
|
|
},
|
2016-05-23 18:52:20 +02:00
|
|
|
],
|
|
|
|
[
|
2016-11-24 10:22:37 +01:00
|
|
|
'date',
|
2016-05-23 18:52:20 +02:00
|
|
|
function ($model) {
|
|
|
|
return Utils::timestampToDateString(strtotime($model->created_at));
|
2017-01-30 20:40:43 +01:00
|
|
|
},
|
2016-05-23 18:52:20 +02:00
|
|
|
],
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function actions()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
[
|
|
|
|
trans('texts.edit_vendor'),
|
|
|
|
function ($model) {
|
|
|
|
return URL::to("vendors/{$model->public_id}/edit");
|
|
|
|
},
|
|
|
|
function ($model) {
|
|
|
|
return Auth::user()->can('editByOwner', [ENTITY_VENDOR, $model->user_id]);
|
2017-01-30 20:40:43 +01:00
|
|
|
},
|
2016-05-23 18:52:20 +02:00
|
|
|
],
|
|
|
|
[
|
2017-01-30 17:05:31 +01:00
|
|
|
'--divider--', function () {
|
|
|
|
return false;
|
|
|
|
},
|
2016-05-23 18:52:20 +02:00
|
|
|
function ($model) {
|
|
|
|
return Auth::user()->can('editByOwner', [ENTITY_VENDOR, $model->user_id]) && Auth::user()->can('create', ENTITY_EXPENSE);
|
2017-01-30 20:40:43 +01:00
|
|
|
},
|
2016-05-23 18:52:20 +02:00
|
|
|
|
|
|
|
],
|
|
|
|
[
|
|
|
|
trans('texts.enter_expense'),
|
|
|
|
function ($model) {
|
|
|
|
return URL::to("expenses/create/{$model->public_id}");
|
|
|
|
},
|
|
|
|
function ($model) {
|
|
|
|
return Auth::user()->can('create', ENTITY_EXPENSE);
|
2017-01-30 20:40:43 +01:00
|
|
|
},
|
|
|
|
],
|
2016-05-23 18:52:20 +02:00
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|