2017-01-30 21:40:43 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Ninja\Datatables;
|
2016-05-23 19:52:20 +03:00
|
|
|
|
|
|
|
|
use Auth;
|
|
|
|
|
use Str;
|
2017-01-30 21:40:43 +02:00
|
|
|
use URL;
|
|
|
|
|
use Utils;
|
2016-05-23 19:52:20 +03:00
|
|
|
|
|
|
|
|
class ProductDatatable extends EntityDatatable
|
|
|
|
|
{
|
|
|
|
|
public $entityType = ENTITY_PRODUCT;
|
2016-11-24 11:46:57 +02:00
|
|
|
public $sortCol = 4;
|
2016-05-23 19:52:20 +03:00
|
|
|
|
|
|
|
|
public function columns()
|
|
|
|
|
{
|
|
|
|
|
return [
|
|
|
|
|
[
|
|
|
|
|
'product_key',
|
|
|
|
|
function ($model) {
|
|
|
|
|
return link_to('products/'.$model->public_id.'/edit', $model->product_key)->toHtml();
|
2017-01-30 21:40:43 +02:00
|
|
|
},
|
2016-05-23 19:52:20 +03:00
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'notes',
|
|
|
|
|
function ($model) {
|
2017-08-11 12:44:45 +03:00
|
|
|
return e(Str::limit($model->notes, 100));
|
2017-01-30 21:40:43 +02:00
|
|
|
},
|
2016-05-23 19:52:20 +03:00
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'cost',
|
|
|
|
|
function ($model) {
|
2017-12-21 10:05:33 +02:00
|
|
|
return Utils::formatMoney($model->cost);
|
2017-01-30 21:40:43 +02:00
|
|
|
},
|
2016-05-23 19:52:20 +03:00
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'tax_rate',
|
|
|
|
|
function ($model) {
|
|
|
|
|
return $model->tax_rate ? ($model->tax_name . ' ' . $model->tax_rate . '%') : '';
|
|
|
|
|
},
|
2017-01-30 21:40:43 +02:00
|
|
|
Auth::user()->account->invoice_item_taxes,
|
|
|
|
|
],
|
2016-05-23 19:52:20 +03:00
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function actions()
|
|
|
|
|
{
|
|
|
|
|
return [
|
|
|
|
|
[
|
|
|
|
|
uctrans('texts.edit_product'),
|
|
|
|
|
function ($model) {
|
|
|
|
|
return URL::to("products/{$model->public_id}/edit");
|
2017-01-30 21:40:43 +02:00
|
|
|
},
|
|
|
|
|
],
|
2017-11-03 11:25:14 +02:00
|
|
|
[
|
|
|
|
|
trans('texts.invoice_product'),
|
|
|
|
|
function ($model) {
|
|
|
|
|
return "javascript:submitForm_product('invoice', {$model->public_id})";
|
|
|
|
|
},
|
|
|
|
|
function ($model) {
|
|
|
|
|
return (! $model->deleted_at || $model->deleted_at == '0000-00-00') && Auth::user()->can('create', ENTITY_INVOICE);
|
|
|
|
|
},
|
|
|
|
|
],
|
2016-05-23 19:52:20 +03:00
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|