2017-01-30 20:40:43 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Ninja\Datatables;
|
2016-05-23 18:52:20 +02:00
|
|
|
|
|
|
|
use Utils;
|
|
|
|
|
|
|
|
class ActivityDatatable extends EntityDatatable
|
|
|
|
{
|
|
|
|
public $entityType = ENTITY_ACTIVITY;
|
|
|
|
|
|
|
|
public function columns()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
[
|
|
|
|
'activities.id',
|
|
|
|
function ($model) {
|
2017-04-25 10:04:36 +02:00
|
|
|
$str = Utils::timestampToDateTimeString(strtotime($model->created_at));
|
2017-11-05 13:10:51 +01:00
|
|
|
$activityTypes = [
|
|
|
|
ACTIVITY_TYPE_VIEW_INVOICE,
|
|
|
|
ACTIVITY_TYPE_VIEW_QUOTE,
|
|
|
|
ACTIVITY_TYPE_CREATE_PAYMENT,
|
|
|
|
ACTIVITY_TYPE_APPROVE_QUOTE,
|
|
|
|
];
|
2017-04-25 10:04:36 +02:00
|
|
|
|
2017-11-05 13:10:51 +01:00
|
|
|
if ($model->contact_id
|
|
|
|
&& ! $model->is_system
|
|
|
|
&& in_array($model->activity_type_id, $activityTypes)
|
|
|
|
&& ! in_array($model->ip, ['127.0.0.1', '192.168.255.33'])) {
|
2017-04-25 10:04:36 +02:00
|
|
|
$ipLookUpLink = IP_LOOKUP_URL . $model->ip;
|
|
|
|
$str .= sprintf(' <i class="fa fa-globe" style="cursor:pointer" title="%s" onclick="openUrl(\'%s\', \'IP Lookup\')"></i>', $model->ip, $ipLookUpLink);
|
2019-01-30 11:45:46 +01:00
|
|
|
} elseif ($model->token_id) {
|
|
|
|
$str .= ' <i class="fa fa-server" title="API"><i>';
|
|
|
|
|
2017-04-25 10:04:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return $str;
|
2017-01-30 20:40:43 +01:00
|
|
|
},
|
2016-05-23 18:52:20 +02:00
|
|
|
],
|
|
|
|
[
|
|
|
|
'activity_type_id',
|
|
|
|
function ($model) {
|
|
|
|
$data = [
|
|
|
|
'client' => link_to('/clients/' . $model->client_public_id, Utils::getClientDisplayName($model))->toHtml(),
|
|
|
|
'user' => $model->is_system ? '<i>' . trans('texts.system') . '</i>' : Utils::getPersonDisplayName($model->user_first_name, $model->user_last_name, $model->user_email),
|
|
|
|
'invoice' => $model->invoice ? link_to('/invoices/' . $model->invoice_public_id, $model->is_recurring ? trans('texts.recurring_invoice') : $model->invoice)->toHtml() : null,
|
|
|
|
'quote' => $model->invoice ? link_to('/quotes/' . $model->invoice_public_id, $model->invoice)->toHtml() : null,
|
2019-05-26 20:22:23 +02:00
|
|
|
'contact' => $model->contact_id ? link_to('/clients/' . $model->client_public_id, Utils::getPersonDisplayName($model->first_name, $model->last_name, $model->email))->toHtml() : Utils::getPersonDisplayName($model->user_first_name, $model->user_last_name, $model->user_email),
|
2019-04-17 17:29:09 +02:00
|
|
|
'payment' => $model->payment ? e($model->payment) : '',
|
2016-05-23 18:52:20 +02:00
|
|
|
'credit' => $model->payment_amount ? Utils::formatMoney($model->credit, $model->currency_id, $model->country_id) : '',
|
|
|
|
'payment_amount' => $model->payment_amount ? Utils::formatMoney($model->payment_amount, $model->currency_id, $model->country_id) : null,
|
2016-10-20 22:17:37 +02:00
|
|
|
'adjustment' => $model->adjustment ? Utils::formatMoney($model->adjustment, $model->currency_id, $model->country_id) : null,
|
|
|
|
'task' => $model->task_public_id ? link_to('/tasks/' . $model->task_public_id, substr($model->task_description, 0, 30).'...') : null,
|
|
|
|
'expense' => $model->expense_public_id ? link_to('/expenses/' . $model->expense_public_id, substr($model->expense_public_notes, 0, 30).'...') : null,
|
2016-05-23 18:52:20 +02:00
|
|
|
];
|
|
|
|
|
2017-01-05 11:46:03 +01:00
|
|
|
$str = trans("texts.activity_{$model->activity_type_id}", $data);
|
|
|
|
|
|
|
|
if ($model->notes) {
|
|
|
|
$str .= ' - ' . trans("texts.notes_{$model->notes}");
|
|
|
|
}
|
|
|
|
|
|
|
|
return $str;
|
2017-01-30 20:40:43 +01:00
|
|
|
},
|
2016-05-23 18:52:20 +02:00
|
|
|
],
|
|
|
|
[
|
|
|
|
'balance',
|
|
|
|
function ($model) {
|
|
|
|
return Utils::formatMoney($model->balance, $model->currency_id, $model->country_id);
|
2017-01-30 20:40:43 +01:00
|
|
|
},
|
2016-05-23 18:52:20 +02:00
|
|
|
],
|
|
|
|
[
|
|
|
|
'adjustment',
|
|
|
|
function ($model) {
|
|
|
|
return $model->adjustment != 0 ? Utils::wrapAdjustment($model->adjustment, $model->currency_id, $model->country_id) : '';
|
2017-01-30 20:40:43 +01:00
|
|
|
},
|
|
|
|
],
|
2016-05-23 18:52:20 +02:00
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|