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

34 lines
1.5 KiB
PHP
Raw Normal View History

2015-03-17 02:30:56 +01:00
<?php namespace App\Http\Controllers;
use Auth;
use DB;
use Datatable;
use Utils;
2015-04-22 23:40:21 +02:00
use View;
2015-03-16 22:45:25 +01:00
2015-04-02 15:12:12 +02:00
class ActivityController extends BaseController
2015-03-16 22:45:25 +01:00
{
public function getDatatable($clientPublicId)
{
$query = DB::table('activities')
->join('clients', 'clients.id', '=', 'activities.client_id')
->where('clients.public_id', '=', $clientPublicId)
->where('activities.account_id', '=', Auth::user()->account_id)
->select('activities.id', 'activities.message', 'activities.created_at', 'clients.currency_id', 'activities.balance', 'activities.adjustment');
return Datatable::query($query)
2015-05-27 19:29:52 +02:00
->addColumn('activities.id', function ($model) { return Utils::timestampToDateTimeString(strtotime($model->created_at)); })
2015-03-16 22:45:25 +01:00
->addColumn('message', function ($model) { return Utils::decodeActivity($model->message); })
->addColumn('balance', function ($model) { return Utils::formatMoney($model->balance, $model->currency_id); })
2015-04-22 23:40:21 +02:00
->addColumn('adjustment', function ($model) { return $model->adjustment != 0 ? self::wrapAdjustment($model->adjustment, $model->currency_id) : ''; })
2015-03-16 22:45:25 +01:00
->make();
}
2015-04-22 23:40:21 +02:00
private function wrapAdjustment($adjustment, $currencyId)
{
$class = $adjustment <= 0 ? 'success' : 'default';
$adjustment = Utils::formatMoney($adjustment, $currencyId);
return "<h4><div class=\"label label-{$class}\">$adjustment</div></h4>";
}
2015-03-16 22:45:25 +01:00
}